.
:
;
;
;
, () .
, , [1]:
[< >][< >]< > ([< >]
{
}
.. return, . . return, .. return.
< . . > void, return .
( ).
void ( ). , .
static extern. static , . extern, , , .
, extern. extern , .
, - static. static , . , , , extern. , static, static.
main() ( ).
, . void, , .
. .
, , . , , , , - . int .
, , , return, . , , , . return return , . , .
|
|
1:
/* */
double linefunc (double x, double a, double b)
{
return (a*x + b);
}
2:
/* n > 0 */
long int pow (int x, int n)
{
int i;
long int p;
p = 1;
for (i = 1; i <= n; i++)
p = p * x;
return p;
}
void main ()
{
int i;
for (i = 0; i < 10; i++)
cout<< i= << i << <<pow (2, i) << << pow (-3, i);
}
- , , . . , .
. , . .
, . , .
, . , . , , , .
auto register. , auto. .
, . , .
- . , , , . , , auto, . , ( ). , , return . .
, return, . , return , return .
3:
/* */
static add (int x, int y) { return (x+y); } | add int. static. , . |
typedef struct { char name [20]; int id; long class; } STUDENT; STUDENT sortstu (STUDENT a, STUDENT b) { return ((a.id<b.id)? a:b); } | STUDENT typedef STUDENT. sortstu STUDENT. . |
char *smallstr (char s1[ ], char s2[ ]) { int i; i = 0; while (s1[i]!='\0'&&s2[i]!='\0') i++; if (s1[i]=='\0'') return (s1); else return (s2); } | , . () . char. , char. |
struct student { char name [20]; int id; long class; }; match (struct student * r, char *n) { int i=0; while (r->name [i] == n[i]) if (r->name [i++] == '\0') return (r->id); return (0); } | match . - student, char. , , char. char . , char *n , char n []. i . id, name n, . |
|
|
. -, , - . , , . -, , . . , . , , , ( ), . , , .
, , ;.
, , . , :
double linefunc ();
double linefunc (double, double, double);
double linefunc (double x, double a, double b);
c .
, , . . .
, , void . , . . void *, . .
|
|
int add(int, int); | , add, int int. |
double calc(); | , calc, double. . |
char *strfind(char *,...); | , strfind, char. , - char. , , . |
void draf(void); | void ( ). void, . |
double (*sum(double, double)) [3]; | sum , double. sum , double. |
int (*select(void)) (int); | , select, . , int int. |
char *p; short *q; int prt(void *); | prt, - , int. p q . |
- , ( ) . , .
:
Ø void:
< > ( [< >] );
Ø // void
< > = < > ( [< >] );
. , , .
int add (int x, int y) { return (x+y); } | void main() { int a = 2; int b = 3; cout<< add(5*a, 4*b); } | x y. 5*a 4*b. |
, .
:
1) ; , , ( , ). void, void, , ().
2) ;
3) ;
|
|
4) return; , .
.
, .