C语言复习资料1(3)

2019-03-29 15:05

}

}

int temp=(int)sqrt(n);//sqrt(n)求出n的平方根并取整 for(i=2;i<=temp;i++)

if(n%i==0)break;

if(i>temp)printf(\

printf(\

输出结果为: 2 3 5 7 11 13 17 19 Press any key to continue

7. #include #include const int M=20; void main() { }

输出结果为: 10 6 4

Press any key to continue

int i,c2,c3,c5; c2=c3=c5=0; for(i=1;i<=M;i++){ }

printf(\

if(i%2==0)c2++; if(i%3==0)c3++; if(i%5==0)c5++;

8. #include void main() { }

输出结果为: 1 5 7 11 13 37

Press any key to continue

三、写出下列每个程序运行后的输出结果 1. #include void main() { }

输出结果为: 6 4

Press any key to continue

int a[10]={12,39,26,41,55,63,72,40,83,95}; int i,i1=0,i2=0; for(i=0;i<10;i++)

if(a[i]%2==1)i1++;else i2++; printf(\ int i,s;

for(i=1,s=0;i<15;i++){ }

printf(\

if(i%2==0 || i%3==0)continue; printf(\s+=i;

2. #include #include void main() { }

输出结果为: worker cadre

Press any key to continue

3. #include

int a[10]={4,5,6,15,20,13,12,7,8,9}; void main() {

int i,s0,s1,s2; s0=s1=s2=0; for(i=0;i<10;i++){

switch(a[i]%3){ case 0:s0+=a[i];break; case 1:s1+=a[i];break; case 2:s2+=a[i];break; } int i;

char *a[5]={\char *p1,*p2; p1=p2=a[0]; for(i=0;i<5;i++){ }

printf(\

if(strcmp(a[i],p1)>0)p1=a[i]; if(strcmp(a[i],p2)<0)p2=a[i];

}

}

printf(\

输出结果为: 42 24 33

Press any key to continue 4. #include void main() { }

输出结果为: 2 3 11

Press any key to continue

5. #include void main() {

int a[3][4]={{1,2,7,8},{5,6,10,6},{9,12,3,4}}; int m=a[0][0]; int ii=0,jj=0;

char a[]=\int i1=0,i2=0,i=0; while(a[i]){ }

printf(\

if(a[i]=='a')i1++; if(a[i]=='b')i2++; i++;

}

int i,j; for(i=0;i<3;i++)

for(j=0;j<4;j++)

if(a[i][j]>m){m=a[i][j];ii=i;jj=j;}

printf(\

输出结果为: 2 1 12

Press any key to continue

6. #include void main() { }

输出结果为: 1 2 3 5 8 13 21 34 Press any key to continue

三、写出下列每个程序运行后的输出结果 1. #include void SB(char ch){

switch (ch){ case 'A':case 'a':

printf(\int a,b;

for(a=1,b=2;b<50;){ }

printf(\

printf(\a=a+b; b=a+b;


C语言复习资料1(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:《记承天寺夜游》课内外比阅读练习及答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: