.


:




:

































 

 

 

 





..

()

. , .

return.

33

 

:

1

220400

()

612233

 

:

..

 

2012


.................................................................................................................. 6

1. ................................................................................................................ 6

1.1 ............................................................... 6

1.2 ................................................................................. 6

1.3 ............................................................ 7

2. ............................................................................................................... 8

2.1 ............................................................................................ 8

2.2 .............................................................................................. 9

3. ( return)................................................................................... 11

4. ........................................................................................................ 13

................................................................................................................. 16

............................................................................................................................. 18

................................................................................................................. 19

, . . , , , . . , .

void. , , ; .

, , . :

}

inline int abs(int obj)

{

// iobj

return(iobj < 0? -iobj: iobj);

}

inline int min(int p1, int p2)

{

//

return(pi < p2? pi: p2);

}

nt gcd(int vl, int v2)

{

//

while (v2)

{

int temp = v2;

v2 = vl % v2;

vl = temp;

}

return vl;

 

 

, . , , . , . main() abs() min() gcd().

 

#include <iostream>

int main()

{

//

cout << " : ";

int i;

cin >> i;

if (!cin) {

cerr << "!? - !\n";

return -1;

}

cout << " : ";

int j;

cin >> j;

if (!cin) {

cerr << "!? - !\n";

return -2;

}

cout << "\nmin: " << min(i, j) << endl;

i = abs(i);

j = abs(j);

cout << ": " << gcd(i, j) << endl;

return 0;

main() main.C.

}

 

. (inline), . , , . , . return.

, . , .

. , . , , , . , . . .

main.C abs(), min() gcd(), . , , : int gcd(int, int); ( , .) ( 17) , , . , . , . . localMath.h:

int gcd(int, int);

inline int abs(int i) {

return(i<0? -i: i);

}

inline int min(int vl.int v2) {

return(vl<v2? vl: v2);

}

. , ( ) . , . , min(), abs() gcd().

main.C, :

: 15

: 123

:

mm: 15

: 3


1.

, . .

1.1

, int double, , int& double*, . void, , :

void sum(vector<int>&, int);

. :

int[10] foo_bar();

:

int *foo_bar();

( .)

, . :

list<char> foo_bar();

. :

const is_equa1(vector<int> vl, vector<int> v2);

++ , int. ++ . is_equal() :

const bool is_equa1(vector<int> vl, vector<int> v2);

 

1.2

. , , , void.

, :

int forf();

int fork(void);

, . , . , :

int manip(int vl, v2); //

int manip(int vl, int v2); //

. , , . . :

void print(int *array, int size);

. . ++ , , . . , . .

1.3

gcd() :

int gcd(int, int);

, int. , .

, gcd() char*?

gcd("hello", "world");

, ? ? , 24 312?

gcd(24312);

, . ++ . :

// gcd("hello", "world")

error: invalid argument types (const char *, const char *) --

expecting (int, int)

: (const char *, const char *) --

(int, int)

// gcd(24312)

error: missing value for second argument

:

double? ?

gcd(3.14, 6.29);

, double int. , . int ( ) , , . , .

gcd(3, 6);

3.

++ . . , . , . , : . . .

, ( ) , .

:

extern double sqrt(double);

extern elem* next_elem();

extern char* strcpy(char* to, const char* from);

extern void exit(int);

. , . , ,

double sr2 = sqrt(2);

sqrt() 2.0. .

. , .

 

2.1

, , - ( ). - , .

:

extern void swap(int*, int*); //

void swap(int*, int*) //

{

int t = *p;

*p =*q;

*q = t;

}

, inline, , register. , - .

2.2

, , . . , , . , .

void f(int val, int& ref)

{

val++;

ref++;

}

f(), val++ , ref++ .

:

int i = 1;

int j = 1;

f(i,j);

j, i. , i, , , j, . , , , , . , . const, , , :

void f(const large& arg)

{

// "arg"

}

, const , , , .

:

extern int strlen(const char*); //

extern char* strcpy(char* to, const char* from);

extern int strcmp(const char*, const char*);

.

, . const , , .





:


: 2017-02-11; !; : 282 |


:

:

, .
==> ...

1367 - | 1222 -


© 2015-2024 lektsii.org - -

: 0.038 .