c语言程序阅读练习.doc

  1. 1、本文档共102页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
c语言程序阅读练习

C语言第1章 [例1.3]求2个数中较大者 #include stdio.h void main() { int max(int x,int y); int a, b, c; scanf(%d, %d, a, b); c=max(a, b); printf(max=%d\n, c); } int max(int x, int y) { int z; if (xy) z=x; else z=y; return (z); } 1.5 编写一个C程序,输出以下信息: ***************************** Very good! ***************************** // chapter1.cpp : Defines the entry point for the console application. // #include stdafx.h int main(int argc, char* argv[]) { printf(******************\n); printf( Very good!\n); printf(******************\n); return 0; } 1.6 编写一个C程序,输入a、b、c3个值,输出其中最大者。 // chapter1.cpp : Defines the entry point for the console application. // #include stdafx.h int max(int a, int b, int c) { int temp; temp=a; if(temp b) temp=b; if(temp c) temp=c; return temp; } int main(int argc, char* argv[]) { int a, b, c; scanf(%d %d %d, a, b, c); printf(max=%d\n, max(a, b, c)); return 0; } ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- C语言第2章 [例2.1]求1×2×3×4×5 [例2.2]有50个学生,要求将他们之中成绩在80分以上的学号和成绩输出 [例2.3]判定2000-2500年中的每一年是否是闰年 [例2.4]求1-1/2+1/3-1/4+…+1/99-1/100 [例2.5]对一个大于或等于3的正整数,判断它是不是一个素数 [例2.6]将例2.1求5!的算法用流程图表示 [例2.7]将例2.2的算用流程图表示。将50名学生中成绩在80分以上者的学号和成绩输出 [例2.8]将例2.3判定闰年的算法用流程图表示 [例2.16]将例2.11表示的算法(求5!)用C语言表示 #include stdio.h main() { int i, t; t=1; i=2; while(i=5) { t=t*i; i=i+1; } printf(“%d”, t); } 例2.17]求例2.14表示的算法(求级数的值)求1-1/2+1/3+…+1/99-1/100 用C语言表示 #include stdio.h main() { int sign=1; float deno=2.0, sum=1.0, term; while(deno=100) { sign=-sign; term=sign/deno; sum=sum+term; deno=deno+1; } printf(“%f”, sum); } 2.4 用传统流程图表示求解以下问题的算法 有两个瓶子A和B,分别盛放醋和酱油,要求将它们互换。 #include stdafx.h int main(int argc, char* argv[]) { int A; int B; A=1; B=2; printf(A=%d B=%d\n, A, B); int C; C=A; A=B; B=C;

文档评论(0)

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

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

版权声明书
用户编号:7065136142000003

1亿VIP精品文档

相关文档