.


:




:

































 

 

 

 


. , ,




 

. .

, , , .

; , () .

, .

:

_[_];

++ . 0, 1, 2 .

 

, , .

 

3_1_1.

# include < iostream >

using std::endl;

using std::cout;

Int main()

{

const int ArraySize=5; //

int a [ ArraySize ] = {12, 3, 42, 5, 34};// :

// a [0]=12, a [1]=3, a [2]=43,

// a [3]=5, a [4]=34

// :

/*

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

cin>>a[i];

*/

for (int i=0; i<ArraySize;++i) //

cout << a [ i ]<< endl; //

int to tal=0; //

for (int i=0; i<ArraySize; ++i) //

total+=a[i];

cout << " : " <<total<<endl;

system("pause");

return 0;

}

 

 

3_1_2.

#include <iostream>

using std::endl;

using std::cout;

Int main()

{

const int ArraySize=5 //

int a[ArraySize] = {12, 3, 42, 5, 34}; //

int i, j, temp;

//

for (i =0; i < ArraySize -1; i ++) //

for (j = ArraySize -1; j > i; j --) //

if (a[j]<a[j-1])

temp=a[j], a[j]=a[j-1], a[j-1]=temp;//

//

for (i =0; i < ArraySize -1;++ i)

cout<<a[i]<<endl; // : 3, 5, 12, 34, 42

system (" pause ");

return 0;

}

 

3_1_3.

#include <iostream>

using std::endl;

using std::cout;

Int main()

{

const int ArraySize1=3, // 1 ( )

ArraySize2=2; // 2 ( )

// :

int a[ArraySize1][ArraySize2] ={ {12, 3}, // a[0][0]=12, a[0][1]=3,

{42, 5}, // a[1][0]=42, a[1][1]=5,

{10, 34} // a[2][0]=10, a[2][1]=34

};

// :

/*

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

for(int j=0; j<ArraySize2; ++j)

cin>>a[i][j];

*/

for (int i=0; i<ArraySize1;++i){ //

for (int j=0; j<ArraySize2; ++j) //

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

cout<<endl;

}

//

int total=0;

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

for (int j=0; j<ArraySize2; ++j)

total+=a[i][j];

cout << " : " <<total<<endl;

system("pause");

return 0;

}

 

 

, .

, , , '\0'.

 

. :

char string1[]= " hello ";

. (string1) = 5 ( " hello ") + 1 ( ) = 6.

, . , :

char string 1[]= {' h ', ' e ', ' l ', ' l ', ' o ', '\0' };

, , . , string1[0] ' h ', string1[5] ' o '.





:


: 2018-10-14; !; : 250 |


:

:

80% - .
==> ...

1699 - | 1555 -


© 2015-2024 lektsii.org - -

: 0.012 .