.


:




:

































 

 

 

 


.




 

( ). - , ( ). :

 

_ (< >)

< >

{

<>

<>

}

 

, (, ). , , .

( main), . . . , . . .

, , ( ) .

. 15 , .

 

97

#include<stdio.h>

main ()

(

int i,print();

for (i=l;i<=15;i++) print();

{

print() /* */

)

printf (" \n);

}

 

( ) , . ) . .

, , , . - , - , . , . , ( ) (. 97). , . : 98, , , z, [1;20] x^2 = ^2 + z^2.

 

98

#include<stdio.h>

main()

(

int , , z, zero();

char p, q, ch();

x=2; y=45; z=0;

q=o;

printf(" "); zero(x);

printf("x+y+(x+y)^z= "); zero(x+y+(x+y)^z);

printf("q= "); ch(q);

}

int zero(u)

int u;

(

printf("%d\n",u);

)

char ch(u)

char u;

{

printf("%c\n",u);

)

:

 

x=2

x+y+(x+y)^z= 94

q=0

 

99

#include<stdio.h>

main()

(

int x,y,z;

int zero();

printf(" :\n");

for (=1;<=20;++)

for (=1;<=20;++)

for (z=l;z<=20;z++)

if (y*y+z*z==x*x)

zero(x,,z);

}

int zero(f,g,h)

int f,g,h;

(

printf ("x= %d, y= %d, 2=%d\n",f,g,h);

)

:

 

= 5, = 3, z= 4

= 5, = 4, z= 3 x= 10, y= 6, z= 8

x= 10, y=8, z=6 x= 13, y=5, z= 12

x= 13, y= 12, z= 5 x = 15, y= 9, z= 12

x= 15, y= 12, z=9 x=17, y=8, z=15 x= 17, y= 15,

z=8 x=20, y=12, z=16

x=20, y= 16, z= 12

 

return; main . return :

 

return (<>);

 

, , .

( ) return (.. return ).

. , 8; 8, .

100

#include<stdio.h>

main()

{

int n, s();

printf(" ");

scant("%d", &n);

if (n<8) printf(=%d", s(n));

else printf(" ");

)

int s(x) /* */

int x;

{

int y,p=l;

for (y=x; y>0; y-) p*=y;

return(p); /* */

}

:

 

1. 4

=24

2. 9

 

: , x2 ( ) ( - , , ).

 

101

 

#include<stdio.h>

main()

(

int , , x, , z;

int odd();

printf("\n x, : ");

scanf("%d %d", &, &); =; =; z=l;

while (b!=0)

if (odd(b))

{ z=z*a; b- -;}

else

(a=a*a; b=b/2;}

printf("\n%d", z);

}

int odd(t)

int t;

(

return((t%2==0)? 0:1);

)

:

 

x, : 15 2

 

, :

( (, , ), , .);

. .

 

function 1();

 

. .

 

function2(&x);

 

. . , , :

 

function l(num)

int num;

 

, , :

 

function2(x)

int *x;

 

, , , . \ \ scanf(). num, scanf(''%d",&num). , , , , .

: .

 

102

 

#include<stdio.h>

main()

{

int , ;

int interchange(); /* int */

x=l; y=3;

printf("... x=l y=3\n");

interchange(&x, &y); /* ( ) */

printf("... x=%d y=%d", , );

}

/* */

int interchange(u, v)

int *u, *v;

(

int p;

p=*\i; *u=*v; *v=p;

}

:

 

=1 =3

=3=1

 

interchange(&x,&y) . , v, interchanage(u,v), , , .

, u v , :

 

int *u,*v; int p;

 

. , : =*u; , u - &, . , *u , . , , :

 

= u; /* */

 

, ., *u = *v = .

, . , , int. int, .

1. :

 

char pun(ch,n) /* */

int n;

char ch;

 

2. . ; ( ) .

 

main()

{

char rch,pun();

 

 

(, , ), - . .

:

 

auto extern

register static

 

(auto) , . , .

. , . , . .

, register, . , . register , . , , register, . .

, extern , . , , . , , . , . . ( ) .

.

. (, ..); , .

, -

 

int max;

char save[maxline];

 

max save, .

 

extern int max;

extern char save[];

 

max int, a save char ( ), .

, , ; extern .

 

103

 

#include<stdio.h>

int i=0;

/* - . - , */

/* . i=0 - . */

main() /* 1. */

(

auto int i=l;

/* 1 i=l - main(). */

/* i=l - /*

/* main(). /*

printf("%d\n", i);

/* , */

/* , */

/* , */

/* 1 i=l. */

{ /* 2. */

int i=2;

/* i=2 - auto. */

/* i=2 - 2, - */

/* 2. 2, -*/

/* 2. */

printf("%d\n", i);

/* i=2. */

{ /* 3. */

i+=l; printf("%d\n", i);

/* i,/*

/* */

/* 3. */

}

/* 2. */

printf("%d\n", i);

/* i=3. */

)

/* 1. */

printf("%d", i);

/* i=3 . */

/* i i=l. */

)

104

#include<stdio.h>

int a;

main()

(

extern int a;

int P ();

a=6; P();

)

int P()

(

extern int a;

printf("a=%d",a);

}

:

 

a=6

 

, . - (.. )

 

static < > < >;

 

. .

( ) ( - ). , .

, , - . , , \ extern.

.

. \ .

105

#include<stdio.h>

main()

(

int count;

int trystat ();

for (count=l; count<=3; count++)

(

printf (" %d:\n", count);

trystat();

}

)

trystat ()

{

int fade=l;

static int stay=l;

printf("fade = %d stay = %d\n", fade++, stay++);

}

:

1:

fade = 1 stay = 1

2:

fade = 1 stay = 2

3:

fade = 1 stay = 3

 

trystat()

trystat()

{

int fade=l;

int stay=l;

printf("fade = %d stay = %d\n", fade++, stay++);

}

 

:

 

1:

fade = 1 stay = 1

2:

fade = 1 stay = 1

3:

fade = 1 stay = 1

A-

 

- . . - . , stdio h , ,

 

#include <stdio.h>.

 

(scanf()) (printf()). , , , .

- . , - . , . : .

- , , . () () . .

- , ( ). , . . stdin, stdout stderr, - ( - ). - .

- getche(), , putchar(), . getche() , , , . putchar() .

, .

 

106

#include<stdio.h>

main()

(

char ch;

ch = getchar();

putchar(ch);

)

 

getche(). getchar() - , . getch(), , getchar(), , getch() .

gets() puts() () . gets() , ( ), , - . puts() - , . , str .

 

107

main ()

(

char str[80];

gets (str);

puts(str);

)

 

puts() , printf() , puts() , .

 

3.4





:


: 2016-11-12; !; : 393 |


:

:

.
==> ...

1347 - | 1295 -


© 2015-2024 lektsii.org - -

: 0.13 .