武汉理工大学《C语言程序设计》实验报告册.docVIP

武汉理工大学《C语言程序设计》实验报告册.doc

  1. 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
武汉理工大学《C语言程序设计》实验报告册

苹果有三个等级,一级5.50元/斤,二级3.00元/斤,三级2.50元/斤。 编写程序,输入苹果的等级,购买的数量和所付的钱数, 输出等级,购买的数量、应付钱数和找零。 #include main int level; double weight,pay,money,charge; printf Please input the level: ; scanf %d,level ; printf Please input the weight you want: ; scanf %lf,weight ; printf Please input the money you pay: ; scanf %lf,pay ; if level 1||level 4||weight 0 printf Data Error\n ; else if level 1 money weight*5.50; else if level 2 money weight*4.20; else if level 3 money weight*3.00; else if level 4 money weight*2.50; charge pay-money; printf \nLevel:%d\nweight:%g\n,level,weight ; printf money:%g\ncharge:%g\n\n,money,charge ; 实验三 循环结构 共20个评委给选手评分,去掉1个最高分,去掉1个最低分,其余18名评委的平均分即选手最终得分 #include main double score,min,max,avg 0; int i; //下面是为了输入第一个数 printf Please input 20 scores...\n ; printf Score 1: ; scanf %lf,score ; min score;max score; avg+ score; // 下面为了输入剩余19个数 for i 2;i 20;i++ do printf Score %d: ,i ; scanf %lf,score ; while score 0 ; if score max max score; avg+ score; avg avg-min-max; avg/ 18; printf \nThe average score is %lf:\n,avg ; 实验四 数组和指针的应用 定义一个有10元素的一位数组count,从键盘上输入8个整数,将其按从大到小的顺序排列,并将排序后的数组输出 数组方法 #include main int count[10],t,i,j; printf Please input 8 numbers:\n ; for i 0;i 8;i++ scanf %d,count[i] ; for i 0;i 8;i++ for j i+1;j 8;j++ if count[i] count[j] t count[i]; count[i] count[j]; count[j] t; printf The sorted array is as follows:\n ; for i 0;i 8;i++ printf %d ,count[i] ; (2) 指针方法 #include main int count[10],t,i,j,*p count; printf Please input 8 numbers:\n ; for i 0;i 8;i++ scanf %d,p[i] ; for i 0;i 8;i++ for j i+1;j 8;j++ if * p+i * p+j t * p+i ; * p+i * p+j ; * p+j t; printf The sorted array is as follows:\n ; for i 0;i 8;i++ printf %d ,count[i] ; 输入2个字符串,将二者连接并输出,再将连接后的字符串反向排列并输出,并求连接后字符串的长度 #include #include main int i,len; char a1[51],a2[26],t[51]; printf Please input 2 strings:\n ; gets a1 ; gets a2 ; strcat a1,a2 ; printf The joint string is: %s,a1 ; len strlen a1 ; printf \nThe len

文档评论(0)

zilaiye + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档