电大C语言程序设计形成性考核册答案(1-4)

2026/4/23 14:35:42

void main()

{

int i,s=0;

for(i=1;i<=6;i++)

s+=i*i;

printf(\

}

输出结果为:

s=91.

Press any key to continue

3. #include

void main()

{

int i,s1=0,s2=0;

for(i=0;i<10;i++)

if(i%2)s1+=i;

else s2+=i;

printf(\

}

输出结果为:

25 20.

Press any key to continue

4. #include

void main()

{

int n=10,y=1;

while(n--){y++;y++;}

printf(\

}

输出结果为:

y=21.

Press any key to continue

5. #include

void main()

{

int f,f1,f2,i;

f1=f2=1;

printf(\

for(i=3;i<=10;i++){

f=f1+f2;

printf(\

if(i%5==0)printf(\

f1=f2;

f2=f;

}

printf(\

}

输出结果为:

1 1 2 3 5

8 13 21 34 55

Press any key to continue

6. #include

#include

void main()

{

int i,n;

for(n=2;n<=20;n++){

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()

{

int i,c2,c3,c5;

c2=c3=c5=0;

for(i=1;i<=M;i++){

if(i%2==0)c2++;

if(i%3==0)c3++;

if(i%5==0)c5++;

}

printf(\

}

输出结果为:

10 6 4

Press any key to continue

8. #include

#include

const int M=20;

void main()

{

int i,s;

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

if(i%2==0 || i%3==0)continue;

printf(\

s+=i;


电大C语言程序设计形成性考核册答案(1-4).doc 将本文的Word文档下载到电脑
搜索更多关于: 电大C语言程序设计形成性考核册答案(1-4) 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

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