1、%d,%d,%da,&b,&c);Maxnum is %dn,maxnum(a,b,c);return 0;int maxnum(int x,int y,int z) int max=x; if(ymax) max = y; if(z max = z; return max;演示4int s1(int n) int j,s; s=0; for(j=1;j=n;j+) s=s+j; return s;int sum(int n) int i,s=0; for(i=1;i=1;i-) n=n+i;n=%dn,n);Input n: func(n);演示6void swap(int a,int b)
2、 int temp; temp=a;a=b;b=temp;swap : a=%d,b=%dn,a,b); int a,b; a=3;b=10; swap(a,b);a=%d,b=%dn演示7int func(int a,int b) int c; c=a+b; return c; int x=6,y=7,z=8,r;r=func(x-,y+,x+y),z-);%dn,r);演示8max(float x,float y) return xy? x:y;,max(2,3.5);演示9 for(i=0; s=s+i; int m,sn;m); sn=sum(m);the sum is %dn,sn)
3、;演示10void swap(int x,int y);int main()input 2 numbers :%d,%db);input number is:a=%d,b=%d ninput 2 numbers is: return 0;void swap(int x,int y) temp = x; x = y; y = temp;swap number is : x = %d,y = %d n,x,y);演示11#define K 3#define N 5long f2(int n,int k) long power = n;k; power *=n; return power;long
4、f1(int n,int k) long sum = 0 ; sum = sum + f2(i,k); return sum;int main(void)sum of %d power of integer from 1 to %d = ,K,N);%ldn,f1(N,K);演示12int min(int a,int b); int j,k,mininum;input 2 integers:j,&k); mininum = min(j,k);n of the two values %d and %d,the mininum is %dn,j,k,mininum);int min(int a,i
5、nt b) if(ax: return z; extern int A,B; /声明外部变量,max(A,B);int A=13,B=-8; /定义外部变量演示15int f1(int xb) extern int xa; return (xa*xb); extern int xb;int xa = 5;xa=%d,xb=%d,result=%d,xa,xb,f1(xa);int xa = 3,xb = 4;演示16void num() extern int x,y; int a=15,b=10; x=a-b; y=a+b;int x,y; int a=7,b=5;x=a+b;y=a-b; n
6、um();%d,%dn演示17 void swap(); extern int a,b; b=10; swap();int a,b;void swap()演示18void auto_static(void) int var_auto = 0; static int var_static = 0;var_auto = %d,var_static = %dn,var_auto+,var_static+); for (i=0;3; auto_static();演示19 int t; t=x;x=y;y=t;-void swap(int ,,int) x,&y); swap(x,y); -演示20in
7、t fac(int n) static int f=1; f=f*n; return f;=5;%d!=%dn,i,fac(i);演示21 int a = 2; int p = a;,a); int a =7;,+a);演示22 p=func(k,m);%d, static int m=0,i=2; return m;演示23f(int n) if(n=6)c=1; c=(f(n+1)+1)*2;,f(1);演示24long power(int n) long f; if(n1) f=power(n-1)*n; f=1; long x;input an integer number: x=po
8、wer(n);=%ldn,n,x);演示25int fact() static int i=5; if(i=0) return 1; i-; return (i+1)*fact();fact=%dn,fact();演示26int fun(int k);int w=3; int w=10;,fun(5)*w);int fun(int k) if(k=0) return w; return(fun(k-1)*k);演示27 register int i,f=1; f=f*i;演示28age(int n) if(n=1)c=10; c=age(n-1)+2;,age(5);演示29#define P
9、I 3.14#define circuit(r) 2*PI*r#define area(r) PI*r*rvoid main() float ra,c,a;%fra);c=circuit(ra);a=area(ra);ra=%f,c=%f,a=%f,ra,c,a);汉诺塔(演示30)void move(int,char,char,char);input n disk on tower A: move(n,A,BCvoid move(int n,char a,char b,char c) static int step=1; if(n=1)step %d :move disk form %c - %cn,step+,a,c); move(n-1,a,c,b); move(1,a,b,c); move(n-1,b,a,c);演示31#define LETTER 1 char str20=C Language,c; i=0; while(c=stri)!=0) i+;#if LETTER if(ca&cz c=c-32;#elseZ c=c+32;#endif printf(%c,c);long f(int n) if(n=1|n=2) return 1; else return f(n-1)+f(n-2); long n;input n:the number is %dn,f(n);
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1