.


:




:

































 

 

 

 


3_4_2.




#include <iostream>

using std::cout;

using std::endl;

Int main()

{

char string1[10], *string2 = "Hello",

string3[10], *string4 = "GoodBye",

* tmp;

// string 2 string 1,

for (int i=0; (string1[i]= string2[i])!= '\0'; ++i) ;

cout<<"string1:"<<string1<<endl;

// string4 string3,

tmp=string3; // tmp, .. string3++

for (; (*tmp = *string4)!= '\0'; tmp++, string4++) ;

cout<<"string3:"<<string3<<endl;

system("pause");

return 0;

}

 

3_4_3.

 

#include <cstring>

#include <iostream>

using std::endl;

using std::cout;

Int main()

{ // strtok

// -

char str[] = " 5 ";

char *tkPtr; //

tkPtr = strtok (str, " ");

while (tkPtr!= NULL) {

cout<<tkPtr<<endl;

tkPtr=strtok(NULL, " ");

}

system("pause");

return 0;

}

 

 

 

. . 3.1. a , x.

3.1

.

a x. f x 1, ++.

3_5_1.

1

# include < iostream >

using std::cout;

using std::endl;

void swap _ values (int * a, int * b) // -

{

int temp =* a; //

*a=*b;

*b=temp;

}

Int main()

{

int x =10, y =20;

swap _ values (& x, & y); // &,

//

cout << x <<" "<< y << endl; // : 20 10

system("pause");

return 0;

}

2

#include <iostream>

using std::cout;

using std::endl;

void swap _ values (int & a, int & b) // -

{

int temp = a; //

a=b;

b=temp;

}

Int main()

{

int x =10, y =20;

swap _ values (x, y); // &

cout << x <<" "<< y << endl; // : 20 10

system("pause");

return 0;

}

 

 

 

, . , , . , . .

 

 





:


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


:

:

- , 20 40 . - .
==> ...

1441 - | 1414 -


© 2015-2024 lektsii.org - -

: 0.009 .