}
}
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
输出结果为: 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
输出结果为: 1 5 7 11 13 37
Press any key to continue
三、写出下列每个程序运行后的输出结果 1. #include
输出结果为: 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
输出结果为: 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
输出结果为: 2 3 11
Press any key to continue
5. #include
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
输出结果为: 1 2 3 5 8 13 21 34 Press any key to continue
三、写出下列每个程序运行后的输出结果 1. #include
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;