计算机C语言程序设计.doc

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
1. Problem A: Hello world! Description Xiao_ming有两个哥哥,大哥叫Da_min,二哥叫Er_min。三兄弟放学回家,父母分别跟他们打招呼。 Input 无 Output 请输出: Hello Da_min, Hello Er_min, Hello Xiao_ming! Sample Input Sample Output Hello Da_min, Hello Er_min, Hello Xiao_ming! HINT 请注意换行符 Append Code #includestdio.h int main() { printf(Hello Da_min,\n); printf(Hello Er_min,\n); printf(Hello Xiao_ming!\n); } Problem B: 求圆的面积和周长 Description 从键盘输入圆的半径,求圆的面积和周长,圆周率取3.14。 Input 输入一个浮点型数据,有效数字不会超过十进制的6位。 Output 输出为两行。 第一行为圆的面积,第二行为圆的周长,格式见sample。 Sample Input 3 Sample Output Area: 28.260000 Perimeter: 18.840000 HINT 了解浮点类型的输入、输出和算术运算符 Append Code 法一 #includestdio.h int main() { double r,p,s; scanf(%lf,r); p=2*3.14*r; s=3.14*r*r; printf(Area: %lf\n,s); printf(Perimeter: %lf\n,p); } 法二 #includestdio.h #define pi 3.14 int main() { double r; scanf(%d,r); printf(Area: %lf\n,pi*r*r); printf(Perimeter: %lf\n,2*pi*r); } 3. Problem C: 平均值 Description 求3个数的平均值。 Input 输入只有一行,为3个较小的整数。 Output 输出为这3个整数的平均值,保留3位小数。 Sample Input 1 2 3 Sample Output 2.000 HINT 注意除法运算对整型数据和浮点型数据是不一样的。 Append Code #includestdio.h int main() { int a,b,c; scanf(%d%d%d,a,b,c); printf(%.3lf,(a+b+c)/3.0); } 4. Problem D: 求字符的值 Description 从键盘输入3个字符(不含双字节字符),分别输出每个字符的十进制值(ASCII码)、八进制值和十六进制值。 Input 输入为3个字符。 Output 输出为3行。 每一行为每个字符(对应输入顺序)的十进制、八进制和十六进制值,用空格分隔开。每个输出的值占3个字符,不足3个字符前面补0。 Sample Input 0 A Sample Output 048 060 030 032 040 020 065 101 041 HINT 了解字符值的存储和整型的关系。 Append Code #includestdio.h int main() { char a,b,c; scanf(%c%c%c,a,b,c); printf(%.3d %.3o %.3x\n,a,a,a); printf(%.3d %.3o %.3x\n,b,b,b); printf(%.3d %.3o %.3x\n,c,c,c); } 5. Problem A: 最简单的程序 Description 输出一行“Hello world!”。 Input 无 Output Hello world! Sample Input Sample Output Hello world! HINT Append Code #includestdio.h int main() { printf(Hello world!); } Problem B: 算术基本运算 Description 计算两整数x和y(0x,y1000)的和、差、积、商、余数、x的平方和y的三次方。 Input 输入只有一行,格式见sample。 Output 输出为多行,按顺序每行输出x,y的和、差、积、商、余数、x的平方和y的三次方,格式见sample Sample I

文档评论(0)

xina171127 + 关注
实名认证
内容提供者

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

1亿VIP精品文档

相关文档