Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АрхитектураБиологияГеографияДругоеИностранные языки
ИнформатикаИсторияКультураЛитератураМатематика
МедицинаМеханикаОбразованиеОхрана трудаПедагогика
ПолитикаПравоПрограммированиеПсихологияРелигия
СоциологияСпортСтроительствоФизикаФилософия
ФинансыХимияЭкологияЭкономикаЭлектроника

Given real numbers x, y1, ., y25. In this sequence find two members, the arithmetic mean of which is closest to x.

Читайте также:
  1. A Decide which of these statements are true (T) or false (F).
  2. A peninsula is a piece of land, which is almost completely surrounded by water, but is joined to a larger mass of land.
  3. A strait is a narrow passage of water between two areas of land, which is connecting two seas.
  4. A) Pronunciation drill. Pronounce the words, then look at the given map and fill in the table below.
  5. A) read the text and tell which of the problems mentioned in the text are typical for the city you live in.
  6. Accommodation is provided at Varley Halls which is part of the University of Brighton.
  7. Adverbial clauses of this type contain some condition (either real or unreal) which makes the action in the main clause possible.

#include <iostream>

using namespace std;

void main()

{ const int N=25;

float k=0,m,n; float y[N]; cout<<"vvedite znachenia"<<endl;

for (int i = 0; i<N; i++) {cin>>y[i];}

float x=0; cout<<"vvedite znachenia x"<<endl;

cin>>x k=abs(x-(y[0]+y[1])/2);

for(int i=0;i<N;i++)

{for(int j=1;j<N;j++)

{if(k>abs(x-(y[i]+y[j])/2)){k=abs(x-(y[i]+y[j])/2); m=i;n=j; } } }

cout<<"m="<<m<<"n="<<n<<endl;}

23) Given a real number n. Get a real square matrix, where i = 1, n, j = 1, n and

include<iostream.h>

int main()

{int i=1,j=1,n;

double a[100][100],m;

cin>>n;

for(i=1;i<=n;i++)

for(j=1;j<=n;j++)

{m=i+j;m=1/m;a[i][j]=m;}

for(i=1;i<=n;i++)

{for(j=1;j<=n;j++)

cout<<a[i][j]<<" ";cout<<endl;}

system("pause"); return 0;}

Given a real square matrix of order 12. Replace with zeros elements on the diagonal and above it.

#include<iostream.h>

void main()

{ int i,j; int a[100][100];

for(i=0;i<12;i++)

for(j=0;j<12;j++)

a[i][j]=rand()%10;

for(i=0;i<12;i++)

{ for(j=0;j<12;j++)

cout<<a[i][j]<<" "; cout<<endl; }

for(i=0;i<12;i++)

{ for(j=0;j<12;j++)

{ if(j>=i) a[i][j]=0; } }

for(i=0;i<12;i++)

{ for(j=0;j<12;j++) cout<<a[i][j]<<" "; cout<<endl; } system("pause"); }

Given a real square matrix of order mxn. Determine the numbers b1,.., bm, which are equal to the sum of the elements of the corresponding row.

#include<iostream.h>

int main()

{ int i,j,m,n,k=0; int a[100][100],b[100];

cin>>m;

for(i=0;i<m;i++) for(j=0;j<m;j++) a[i][j]=rand()%10;

for(i=0;i<m;i++) { for(j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl; }

for(k=0;k<m;k++)

b[k]=0; k=0;

for(i=0;i<m;i++)

{ for(j=0;j<m;j++) { k+=a[i][j]; if(j==m-1)

{ cout<<k<<endl; k=0; } } }

system("pause"); return 0;}

Given a real square matrix of order mxn. Determine the numbers b1,.., bm, which are equal to the product of the elements of the corresponding row.

#include<iostream.h>

int main()

{ int i,j,m,n,k=1;

int a[100][100],b[100];

cin>>m;

for(i=0;i<m;i++)

for(j=0;j<m;j++)

a[i][j]=rand()%10;

for(i=0;i<m;i++)

{ for(j=0;j<m;j++)

cout<<a[i][j]<<" ";

cout<<endl; }

k=1;

for(i=0;i<m;i++)

{ for(j=0;j<m;j++)

{ k*=a[i][j];

if(j==m-1)

{ cout<<k<<endl; k=1; } } }

system("pause");

return 0;}

 


Дата добавления: 2015-11-16; просмотров: 64 | Нарушение авторских прав


<== предыдущая страница | следующая страница ==>
Given a positive integer n, the integers a1, ..., an. Find the number and the sum of the members of the sequence that are divisible by 3 and not divisible by 5.| Объектно-ориентированное программирование

mybiblioteka.su - 2015-2024 год. (0.005 сек.)