1、 i=nl; j=n2; while(ij) t=si; si=sj; sj=t; i+; j-; main() int a10=1,2,3,4,5,6,7,8,9,0,k;fun(a,0,3); fun(a,4,9); fun(a,0,9); for(k=0;k10;k+)printf(“%d”,ak); printf(“n”);程序运行的结果是#include The ladder has %d stages.n,i);#define ROW 3#define COL 4 int matrixAROWCOL=11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2
2、1, 22; int matrixBCOLROW; int i,j;%d*%d:n,ROW,COL); for( i=0; iROW; i+ ) for( j=0; jCOL; j+ ) matrixBji = matrixAij; MatrixB,COL,ROW); for( j=0; printf(%8d,matrixBij); printf(#define N 10 int primesN; int pc,m,k;n The first %d prime numbers are:,N); primes0=2; pc =1; m =3; while(pcN) k=0; while(prim
3、esk*primeskvoid fun(char *s ,int n) char *t;int i,j; for(i=0;in-1;i+) for(j=i+1;jstrlen(sj) t=si;si=sj;sj=t; char *ss=“bcc”,”bbcc”,”xy”,”aaaacc”,”aabcc” ;fun(ss,5); printf(“%s,%sn”,ss0,ss4);void fun(char *a, char *b) while(*a=*) a+; while(*b=*a) b+;a+; char *s=”*a*b*”,t80;fun(s,t);puts(t); FILE *fp;
4、int a10=1,2,3,i,n;fp=fopen(“dl.dat”,”w”);for(i=0;3;i+) fprintf(fp,”%d”,ai);fprintf(fp,”n”);fclose(fp);fp=fopen(“dl.dat”,”r”);fscanf(fp,”%d”,&n);printf(“%dn”,n); void swap( int *a, int *b ) int *t ; t=a; a=b; b=t; int i=3,j=5,*p=&i,*q=&j; swap(p,q); printf(“%d %dn”,*p,*q);int circle(int n, int d) int
5、 s=0,m=n; while(m) s=s*d+m%d; m/=d; return s=n;int num=232,27,851;int scale=2,10,16;sizeof(num)/sizeof(num0); for(j=0;sizeof(scale)/sizeof(scale0); if(circle(numi,scalej) printf(%d - (%d) is a Circle Number!,numi,scalej); else (%d) is not a Circle Number!#define NULL 0int *search2(int *pa,int *pb,in
6、t an,int bn) int *ca,*cb; ca=pa;cb=pb; while(capa+an&cbpb+bn) if(*ca cb+; return ca;/*返回在这两个数表中找到相等元素*/ return NULL;main( ) int *vp,i; int a =1,3,5,7,9,13,15,27,29,37; int b =2,4,6,8,10,13,14,27,29,37; puts(The elements of array a is:sizeof(a)/sizeof(a0); %d,ai);nThe elements of array b is:sizeof(b)
7、/sizeof(b0);,bi); vp=search2(a,b,sizeof a/sizeof a0,sizeof b/sizeof b0); if(vp) printf(nThe first same number in both arrays is %dn,*vp); else printf(Not found! int i, j; i=1;=5) j=1; ch=a while(j0) t=ai; ai=ahigh; ahigh=t; high-; else if(ai=0) i+; ai=alow; alow=t; low+;int s=8,4,0,-1,6,0,-5; int i;
8、n The arry before rest is:sizeof(s)/sizeof(s0);,si); rest(s,sizeof(s)/sizeof(s0);n The arry after rest is:typedef struct char name9; char sex; float score2; STU;void f( STU a) STU b=“Zhao” ,m,85.0,90.0 ;strcpy(a.name,b.name);a.sex=b.sex;2;i+) a.scorei=b.scorei; STU c=“Qian”,p,95.0,92.0;f(c);printf(“
9、%s,%c,%2.0f,%2.0fn”,c.name,c.sex,c.score0,c.score1); #include main() int x,y,z,j=0;n The possible plans to buy 100 fowls with 100 Yuan are:nn for(x=0;x=20;x+) for(y=0;y0) fun(x/2); printf(“%d ”,x); fun(3);#define MAX(a,b) (ab)?a:b int x, y; x=25; y=56;the result is: %dn, MAX(x,y); #include #define R
10、OWS 4#define COLS 4int numsROWSCOLS=1000,1000,1000,1000, 900,500,400,100, 90,50,40,10, 9,5,4,1;char *romsROWSCOLS=m, cmdcdcxclxlxixvivi;main(int argc,char *argv ) int low=1000,high=1012; char roman25; for(;lowlow+) to_roman(low,roman);%dt%sn,low,roman);to_roman(int decimal,char roman ) int power,ind
11、ex; roman0=0 for(power=0;powerROWS;power+) for(index=0;index=numspowerindex) strcat(roman,romspowerindex); decimal-=numspowerindex; int Fun(int x) static int y = 0;y += x;return y; int x = 10, y = 0, k;for(k=0; k k+)y = Fun(x);y = %dn, y);运行结果是:main ( ) char a = programming , b = language ; char *p1
12、, *p2 ; int i; p1 = a;p2 = b; for (i=0;7; i+) if (*(p1+i) = *(p2+i) %c ,*(p1+i) ;int a=10; int a=15; printf(“a.1=%d,”,a);printf(“a.2=%dn”,a);int i=0; while(1)printf(“*”); if(i3) break;printf(“n”);int runc(int a,int b)return(a+b);int x=2,y=5,z=8,r;r=runc(runc(x,y),z);printf(“%dn”,r);执行结果是:#incude a,(
13、p+)-a) ;阅读以下程序并写出其结果func (int a,int b) static int m=0,i=2; i+=m+1; m=i+a+b; return (m); int k=4,m=1,p1,p2; p1=func(k,m) ; p2=func(k,m) ; printf(“%d,%dn”,p1,p2) ;struct man char name20 ; int age ; person = “liming”, 18, “wanghua”, 19,”zhangping”,20 ; int old = 0 ; struct man *p=person, *q ; for ( ; p=&person2; p+) if (oldage) q=p ; old=p-age ; printf(“$s %dn”,q-name,q-age) ;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1