.


:




:

































 

 

 

 


if switch




if :

if () ;

else ;

int test = 65;

if (test >= 90)

{
cout << " , 5!" << endl;

cout << " " << test << endl;

}
else
{
cout << " !" << endl;

cout << " " << 100 - test_score <<"" << endl;

}

switch:

:

char grade=A;

switch(grade)

{

caseA: cout<<, <<endl; break;

caseB: cout<<, ”<<endl;break;

default: cout<<! !<<endl;break

}

 

(while):

while () ;

(do while):

do while ();

: do while while, .. () () . , while (), , do while , ().

(for): for (; ; ) ;

, , , . , .

; , .

. .

: for . for , .

, {}.

: 1 10 while, do while, for.

while:

int i=1;

while (i <= 10)

{

cout<<i<< ;

i++;

}

cout<<endl;

i++;

do {

cout<<i<< ;

i++;

} while (i<=10);

do while:

int i=1;

i++;

do {

cout<<i<< ;

i++;

} while (i<=10);

for:

int s;

for (int i=1, s=0; i <= 10; i++) s=s+i;

, , {} ( Pascal begin end).

 

 

 

1

1. 3 , .

2. , , .

3. , 10- ( for, while, do while).

 

2

1. , , .

2. , a b , , .

3. 1 10 ( for, while, do while).

 

3

1. , . , .

2. , : , .

3. , n, n- ( for, while, do while).

 

4

1. , .

2. , , , .

3. 5 25 ( for, while, do while).

 

5

1. , , .

2. , .

3. 10 15 ( for, while, do while).

 

6

1. M(n, p).

2. ax2 + bx + c=0.

3. 15 25 ( for, while, do while).

 

7

1. , V V=1/3(Q+q+ )h, Q,q , h

2. , =n-p, n>p M=p-n, n<=p.

3. 5 16 ( for, while, do while).

 

8

1. _=-100.

2. ax2+bx+c=0.

3. 1 10 ( for, while, do while).

9

1. .

2. , , .

3. 16 30 ( for, while, do while).

 

10

1. x=-y2-a.

2. , , .

3. 10 20 10 ( for, while, do while).

 

2

: , .

, .

_ _[-_];

_ ;

_ ;

-_ ;

:

float massiv1[10];// 10

int massiv2[20];// 20

. , :

int mas[]={1,2,3,4,5,8}//

, . , , :

int mas[8]={1,2,3};

:

massiv1[1], massiv2[19]

, ++ 0 , . , massiv2 (. 1) 20- massiv2[20]=1, . ( ), .

: 10. . .

.

:

int matrical[5][5];

:

1. ( )

int mat1[][2]={{1,1},{2,2},{3,3}};

2. ,

int mat2[3][2]={1,1,0,2,2,3};

: matrica[1][1].

: 0 20 .

Void main()

{int mas_1[10]

int mas_2[5][5];

for (int i=0; i<10; i++){

//srand (time(0));

mas_1[i]=rand()%20;

cout<<mas_1[i]<< ;

}

cout<<endl;

for(int i=0; i<5; i++){

for(int j=0; j<5; j++){

mas_2[i][j]=rand()%20;

cout<<mas_2[i][j]<< ;

}

cout<<endl;

}

}

 

 

1

1. a b.

2. A B.

 

2

1. .

2. A[i, j] B[i, j].

 

3

1. a n B m´n.

2. A[n, m] B[n, m].

 

4

1. .

2. A[n, m] B[n, m]. 2.

 

5

1. a b. 3.

2. A[n, m] .

 

3

( , )

: , , .

.

:

enum _{1, 2, 3,};

:

, :

_ _;

enum _{1, 2, 3,} _;

:

, . , : (Red), (Yellow) (Green). Red, Yellow, Green, , , .

, :

Const int Red = 0;

Const int Yellow = 1;

Const int Green = 2;

:

enum COLOR { Red, Yellow, Green};

: , . .

:

enum COLOR {Red = 13, Yellow = 1, Green};

Green - 2.

( )

, , , , ..

:

struct _

{

_1 _1;

_2 _2;

};

:

,

_ _;

(),

struct

{

_1 _1;

_2 _2;

} _;

++ ( ):

_1 _1;

_2 _2;

: . .

Struct Tcomplex

{

float re, im;

} a, b, c;

// a

cout<<vvedite deystvitelnyu chast 1-go komplexnogo chisla;

cin>>a.re;

cout<<endl;

cout<<vvedite mnimyu chast 1-go komplexnogo chisla;

cin>>a.im;

cout<<endl;

// b

cout<<vvedite deystvitelnyu chast 2-go komplexnogo chisla;

cin>>b.im;

// a b

c.re=a.re+b.re;

c.im=a.im+b.im;

//

cout<<summa chisel<<c.re<<+<<c.m<<i;

 

:

union _

{

_1 _1;

_2 _2;

};

:

_._1;

_._2;

:

union Rastoyn

{

int miles;

long meters;

};

Rastoyn t;

t.miles=5;

cout<< <<t.miles<<endl;

t.meters=10 000;

cout<< <<t.meters<<endl;

 

 

1

1. STUDENT, :

NAME - ;

;

( ).

2. , :

, STUDENT; ;

, , 4,0;

, .

2

1. AEROFLOT, :

;

;

.

2. , :

, AEROFLOT; ;

, , , ;

, .

 

 

4

: .

, , . . .

:

(, ) , ().

__ _( );

__ , , ( ). , void.

, . . ( ).

, main.

: , .

float funk (int, int);//

void main()// ( )

{}

:

, . , main. , , . , return.

: , 1.

#include <math.h>

float funk (int, int); //

void main()// ( )

{}

float funk (int a, int b) //

{

return sqrt(a*a+b*b);

}

:

, . void, .

:

#include <math.h>

float funk (int, int); //

 

void main()// ( )

{

int val1, val2;

cin<<val1;

cin<<val2;

cout>> funk(val1, val2)<<endl;//

float a = 1+funk(5,5);//

cout>>a;

}

 

float funk(int a, int b)//

{

return sqrt(a*a+b*b);

}

.

: .

, . , . 1, 2, 3 .

, . &:

: .

void obmen(int &a, int &b);

void main()

{

int c=2, d=3;

cout>>c>>endl;

cout>>d>>endl;

obmen(c,d);

cout>>c>>endl;

cout>>d>>endl;

}

void obmen(int &a, int &b)

{

int x=a;

a=b;

b=x;

}





:


: 2016-12-07; !; : 297 |


:

:

! . .
==> ...

1696 - | 1482 -


© 2015-2024 lektsii.org - -

: 0.117 .