:
, , :
- , , ;
- ;
- ;
- () . . 0 N -1, N ;
- , (for, while);
- , . . .
10 0 49:
#include "stdafx.h"
#include "stdlib.h"
#include "time.h"
#include "iostream"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
float mas[10];
srand(time(NULL));
for (int i=0;i<10;i++)
{
mas[i]=rand()%50;
cout<<"mas["<<i<<"]="<<mas[i]<<"\n";
}
system("pause");
return 0;
}
:
#include "stdafx.h"
#include "stdlib.h"
#include "time.h"
#include "iostream"
#include <iomanip>
using namespace std;
#define Nx 5
#define Ny 6
int _tmain(int argc, _TCHAR* argv[])
{
float mas[Nx][Ny];
srand(time(NULL));
for (int i=0;i<Nx;i++)
{
for (int j=0;j<Ny;j++)
{
mas[i][j]=rand()%51;
cout<<setw(5)<<mas[i][j];
}
cout<<"\n";
}
system("pause");
return 0;
}
4.3
4.3.1
1. , 5 , . .
.
<Enter>
[1]-> 12
[2]-> 0
[3]-> 3
[4]-> -1
[5]-> 0
3
2. , . (, , ).
.
(5 ) <Enter>
-> 23 0 45 -5 12
: -5
3. , . (, , ).
|
|
(10 )
<Enter>.
-> 23 0 45 -5 12 0 -2 30 0 64
: 184
: 7
: 23.86
4. , . (, , ).
min max .
(10 )
-> 12 10 5 7 15 4 10 17 23 7
: 4
: 23
. min max : 10.36
5. , ( ) . . (, , ).
.
-> 12
-> 10
-> 16
-> 18
-> 17
-> 16
-> 14
: 14.71 .
4.3.2
1. , .
2. , .
3. , . . . , , .
.
:
-> 12
-> 10
-> 7
-> 1
12
10
7
1
<Enter>
4. , .
5. , , .