欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    C语言程序设计苏小红版第五六单元答案.doc

    • 资源ID:17407622       资源大小:228.50KB        全文页数:14页
    • 资源格式: DOC        下载积分:15金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要15金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    C语言程序设计苏小红版第五六单元答案.doc

    【精品文档】如有侵权,请联系网站删除,仅供学习与交流C语言程序设计苏小红版第五六单元答案.精品文档.第五章5.1#include<stdio.h>void main()double x;printf("请输入一个实数:n");scanf("%lf",&x);if(x>0)printf("%fn",x);elseprintf("%fn",-x);5.2#include <stdio.h>main()int a,b;printf("请输入一个整数:");scanf("%d",&a);b=a%2;if(b=0)printf("%d为偶数n",a);elseprintf("%d为奇数n",a);5.3#include<stdio.h>#include<math.h>main()float a,b,c,s,area;printf("请输入三边长:");scanf("%f,%f,%f",&a,&b,&c);s=(a+b+c)/2;area=(float)sqrt(s*(s-a)*(s-b)*(s-c);if(a+b>c)&&(a+c>b)&&(b+c>a)printf("这个三角形的面积为%fn",area);elseprintf("这三条边不能组成三角形n");5.4#include<stdio.h>#include<math.h>void main() double a,b,c,d,e,x1,x2; printf("请输入a,b,c:"); scanf("%lf,%lf,%lf",&a,&b,&c); if(a=0) printf("该方程不是一元二次方程.n"); else if(b*b-4*a*c>0) d=sqrt(b*b-4*a*c); x1=(-b+d)/(2*a); x2=(-b-d)/(2*a); printf("x1=%f,x2=%fn",x1,x2); else if(b*b-4*a*c=0) x1=(-b)/(2*a); printf("x1=x2=%fn",x1); else if(b*b-4*a*c<0) printf("该方程没有实数解.n");5.5#include<stdio.h>main()int year,flag;printf("输入年份:");scanf("%d",&year);if(year%4=0)&&(year%100!=0)|(year%400=0)flag=1;elseflag=0;if(flag=1)printf("%d是闰年n",year);elseprintf("%d不是闰年n",year);5.6#include<stdio.h>void main()int year,flag;printf("输入年份:");scanf("%d",&year);flag=(year%4=0)&&(year%100!=0)|(year%400=0)?1:2; if(flag=1)printf("%d年是闰年n",year);elseprintf("%d年不是闰年n",year);5.7#include<stdio.h>main()char ch;printf("请输入一个字母:");ch=getchar();if(ch>=65)&&(ch<=90)ch=ch+32;printf("%c,%dn",ch,ch);else if(ch>=97)&&(ch<=122)ch=ch-32;printf("%c,%dn",ch,ch);elseprintf("%cn",ch);5.8#include<stdio.h>main()char ch;printf("请输入一个字符:");ch=getchar();if(ch>=48)&&(ch<=57)printf("这是一个数字字符.n");else if(ch>=65)&&(ch<=90)printf("这是一个大写字母.n");else if(ch>=97)&&(ch<=122)printf("这是一个小写字母.n"); else if(ch=32)printf("这是一个空格字符.n");elseprintf("这是一个其它字符.n");5.9#include<stdio.h>main()int score,mark;printf("Please enter score:");scanf("%d",&score); if(score<0|score>100)printf("Input error!n");else if(score>=90&&score<=100)printf("%d-An",score);else if(score>=80&&score<90)printf("%d-Bn",score);else if(score>=70&&score<80)printf("%d-Cn",score);else if(score>=60&&score<70)printf("%d-Dn",score);elseprintf("%d-En",score);5.10#include <stdio.h>#include <stdlib.h>main()int flag, year,month,day,day1=31,day2=30,day3=29,day4=28;printf("请以2012,03这种形式输入某年某月 :");scanf("%d,%d",&year,&month);if (month>12|month<1)printf("你输入的年份不在合法范围内n");exit(0);elseflag=(year%4=0 && year%100 !=0|year% 400 =0)?1:0; switch (flag)case 1:printf("闰年");break;case 0:printf("平年");break;if (month=2&&flag=1)day=day3;else if (month=2&&flag=0)day=day4;switch (month)case 1:case 3:case 5:case 7:case 8:case 10:case 12:printf("%d年,%d月拥有的天数是31. n",year,month);break;case 4:case 6:case 9:case 11:printf("%d年,%d月拥有的天数是30. n",year,month);break;default:printf("%d年,%d月拥有的天数是%d: n",year,month,day);本章实验题1#include<stdio.h>main() double faheight,maheight;char sex,sports,diet,F,M,Y,N;printf("请输入父母的身高:n");scanf("%lf,%lf",&faheight,&maheight);printf("请输入孩子是男孩还是女孩(F/M):n");scanf(" %c",&sex);printf("请输入孩子是否喜欢锻炼身体(Y/N):n");scanf(" %c",&sports);printf("请输入孩子是否有良好的饮食习惯(Y/N):n");scanf(" %c",&diet);if(sex=77&&sports=89&&diet=89)printf("该孩子成人时身高约为:%.2f.n",(faheight+maheight)*0.54*1.02*1.015);else if(sex=77&&sports=89&&diet=78)printf("该孩子成人时身高约为:%.2f.n",(faheight+maheight)*0.54*1.02);else if(sex=77&&sports=78&&diet=89)printf("该孩子成人时身高约为:%.2f.n",(faheight+maheight)*0.54*1.015);else if(sex=77&&sports=78&&diet=78)printf("该孩子成人时身高约为:%.2f.n",(faheight+maheight)*0.54);else if(sex=70&&sports=89&&diet=89)printf("该孩子成人时身高约为:%.2f.n",(faheight*0.923+maheight)/2*1.02*1.015);else if(sex=70&&sports=89&&diet=78) printf("该孩子成人时身高约为:%.2f.n",(faheight*0.923+maheight)/2*1.02);else if(sex=70&&sports=78&&diet=89)printf("该孩子成人时身高约为:%.2f.n",(faheight*0.923+maheight)/2*1.015);else if(sex=70&&sports=78&&diet=78)printf("该孩子成人时身高约为:%.2f.n",(faheight*0.923+maheight)/2);本章实验题2#include<stdio.h>main()double t,w,h;printf("请输入体重身高:n");scanf("%lf,%lf",&w,&h);t=w/(h*h);if(t<18)printf("低体重.n"); if(t>=18&&t<25)printf("正常体重.n");if(t>=25&&t<27)printf("超重体重.n");if(t>=27)printf("肥胖.n");第六章6.1(1)#include <stdio.h>main()int i,j,k;char space=' 'for (i=1;i<=4;i+)for (j=1;j<=i;j+)printf("%c",space);for (k=1;k<=6;k+)printf("*");printf("n");6.1(2)#include <stdio.h>main()int k=4,n;for (n=0;n<k;n+)if (n%2=0) continue;k-;printf("k=%dn,n=%dn",k,n);6.1(3)#include <stdio.h>main()int k=4,n;for (n = 0;n < k;n+)if (n%2 =0) break;k-;printf("k=%d,n=%dn",k,n);6.2(1)#include <stdio.h>main()int i,sum = 0;for (i=1;i<=101;i=i+2)sum=sum+i;printf("sum = %dn",sum);6.2(2)#include <stdio.h>main()long i;long term,sum = 0;for (i=1;i<=99;i=i+2)term=i*(i+1)*(i+2);sum=sum+term;printf("sum =%ldn",sum);6.2(3)#include <stdio.h>main()long term=0,sum=0;int a,i,n;printf("Input a,n:");scanf("%d,%d",&a,&n);for (i = 1;i<=n;i+)term = term * 10 + a;sum=sum+term;printf("sum = %ldn",sum);6.2(4)#include<stdio.h>#include<math.h>main()int n = 1;float term = 1.0,sign = 1,sum = 0;while (fabs(term) >= 1e-4)term = sign / n;sum = sum + term;sign = -sign;n+;printf("sum = %fn");6.2(5)#include<stdio.h>#include<math.h>main()int n = 1,count = 1;float x;double sum,term;printf("Input x:");scanf("%f",&x);sum = x;term = x;doterm = -term*x*x/(n+1)*(n+2);sum = sum + term;n = n + 2;count+;while (fabs(term)>=1e-5);printf("sin(x) = %f,coumt = %d n",sum,count);6.3#include<stdio.h>main()int x=1,find=0;while (!find)if (x%2=1 && x%3=2 && x%5=4 && x%6=5 && x%7=0)find=1;x+; printf("x=%dn",x-1);6.4#include<stdio.h>main()int i,n;long p,j;printf("Please enter n:");scanf("%d",&n);for (i=1;i<=n;i+)p=i*i;j=i*i*i;printf("%d * %d = %ldn",i,i,p);printf("%d * %d * %d= %ldn",i,i,i,j);6.5#include<stdio.h>main()double C,F,i;for (F = -40;F <= 110;F = F + 10)C = (F-32)*5/9;printf("F=%f C=%fn",F,C);6.6#include<stdio.h>main()double p = 1 + 0.01875*12,x4,x3,x2,benjin;x4 = 1000/p;x3 = (x4 + 1000)/p;x2 = (x3 + 1000)/p;benjin = (x2 + 1000)/p;printf("本金为:%f",benjin);6.7#include<stdio.h>main()double count = 0, c , d , sum = 100;printf("Input c :");scanf("%lf",&c);d = c / 100.0;dosum = sum * (1+d);count+;while (sum <= 200);printf("count = %fn",count);6.8#include<stdio.h>#include<math.h>main()int count = 1;double sum = 1.0 ,term,n = 3.0,i = 1.0;do term = -i/n;sum = sum + term;n = n + 2;i = -i;count+;while (fabs(term) >= 1e-5);printf(" = %lf,count = %d.n",4 * sum,count);6.9#include <stdio.h>#include <math.h>main()int count = 1;double sum = 1.0 , term = 1.0, n = 1.0;while (fabs(term) >= 1e-5)term = term / n;sum = sum + term;n+;count+;printf("e = %lf,count = %d.n",sum,count);6.10#include <stdio.h>main()int i , a , b , c ,d;for (i = 100 ; i <= 999 ; i+)a = i /100; c = i % 10; b = (i - a * 100 - c) / 10;d = a * a * a + b * b * b + c * c * c;if (i = d)printf("i = %dn",i);6.11#include <stdio.h>main()long m = 2 , n , term = 1 ,sum = 1;printf("Input n:");scanf("%ld",&n);do term = term * m;sum = sum + term ;m+;while(sum <= n);printf("m = %d.n",m - 2);6.12#include <stdio.h>main()int num = 1,sum = 0 , count = 0;while (num > 0)printf("Input num :");scanf("%d",&num);sum = sum + num ;count+;printf ("sum = %d,count = %d.n",sum, count - 1);6.13#include <stdio.h>main()int term , sum = 0 , count = 0;do begin:printf("Input term : ");scanf ("%d",&term);if (term > 0)sum = sum + term ;count+;else if (term < 0)goto begin;else goto end ;while (term != 0);end : printf ("sum = %d. count = %d.n",sum,count );6.14#include <stdio.h>main()int a,b,c;for (a = 0;a < 17;a+)for (b = 0;b <= 25 ;b+)c = 30 - a - b ;if (a * 3 + b * 2 + c = 50)printf ("男 = %d,女 = %d,孩子 = %d.n",a,b,c);6.15#include<stdio.h>main()int a,b;for (a = 0; a <=98 ; a+)b = 98 - a;if (a * 2 + b * 4 = 386)printf ("鸡有%d只,免有%d只.n",a,b);6.16#include <stdio.h>main()int x,y,z;for (x = 0;x <= 20;x+)for (y = 0;y <= 33;y+)z = 100 - x - y;if (5 * x + 3 *y + z / 3.0 = 100)printf ("x = %d,y = %d,z = %dn",x, y, z);6.17不确定#include<stdio.h>main()int x, y, z;for (x = 1; x < 10; x+)for (y = 1; y < 20; y+)z = 50 - x - y;if (x * 10 + y * 5 + z = 100)printf("x = %d, y = %d, z = %dn",x ,y ,z);6.18上:#include<stdio.h>main()int i, j;for (i = 1; i <= 9; i+)for (j = 1; j <= 9; j+)printf("%-5d",i * j);printf("n");左:#include<stdio.h>main()int i, j;for (i = 1; i <= 9; i+)for (j = 1; j <= i; j+)printf("%-5d",i * j);printf("n");右:#include <stdio.h>main()int i, j, a = 1, k;char b = ' 'for (i = 1; i <= 9; i+)for (k = 1; k <= i; k+)printf("%5c",b);for(j = i; j <= 9; j+)a=j * i;printf("%5d",a);printf("n");6.19#include<stdio.h>main()long i,summo;double sumfu = 0,term = 0.01;summo = 100000 * 30;for (i = 1;i <= 30;i+)term = term * 2.0;sumfu = sumfu + term;printf("陌生人付%ld,富翁付%lf.n",summo,sumfu );本章实验题2.1#include<stdio.h>#include<stdlib.h>#include<time.h>main()int x1, x2, c, answer;begin:srand(time(NULL);x1 = rand() % 10 + 1;x2 = rand() % 10 + 1;c = x1 * x2;do printf ("%d * %d = n",x1, x2);scanf("%d",&answer);if (c = answer)printf("Right !n");goto begin;else printf("Wrrong !Please try again.n");while(c != answer);2.2#include<stdio.h>#include<stdlib.h>#include<time.h>main()int x1, x2, c, answer, count = 0;begin:srand(time(NULL);x1 = rand() % 10 + 1;x2 = rand() % 10 + 1;c = x1 * x2;do printf ("%d * %d = n",x1, x2);scanf("%d",&answer);if (c = answer)printf("Right !n");goto begin;else printf("Wrrong !Please try again.n");count+;while(c != answer)&&(count <= 2);printf ("Wrong ! You have tried three times ! Test over !n");2.3#include<stdio.h>#include<stdlib.h>#include<time.h>main()int count1 = 0, count2 = 0;int x1, x2, c, answer ,i;for (i = 1;i <= 10; i+)srand(time(NULL); x1 = rand() % 10 + 1; x2 = rand() % 10 + 1; c = x1 * x2;printf ("%d * %d = n",x1 , x2 );scanf("%d",&answer);if (c = answer)printf ("Right !n");count1+;else printf ("Wrong !n");count2+;printf ("你得了%d分.n正确率为%d %.n",count1,count1 *10);

    注意事项

    本文(C语言程序设计苏小红版第五六单元答案.doc)为本站会员(豆****)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开