- 8
- 0
- 约1.08万字
- 约 91页
- 2018-04-04 发布于河南
- 举报
2016-学习资料大全:C语言编程经典100例.doc
C语言经典编程100例
程序1】3个月起每个月都生一对兔子,小兔子长到第三个月1.程序分析: 兔子的规律为数列1,1,2,3,5,8,13,21....2.程序源代码:main long f1,f2;int i;f1 f2 1;for i 1;i 20;i++ printf %12ld %12ld,f1,f2 ; if i%2 0 printf \n ;/*控制输出,每行四个*/f1 f1+f2; /*前两个月加起来赋值给第三个月*/f2 f1+f2; /*前两个月加起来赋值给第三个月*/ 【程序2】101-200之间有多少个素数,并输出所有素数。1.程序分析:判断素数的方法:用一个数分别去除2到sqrt 这个数 ,如果能被整除,2.程序源代码:#include math.hmain int m,i,k,h 0,leap 1; printf \n ; for m 101;m 200;m++ k sqrt m+1 ; for i 2;i k;i++ if m%i 0 leap 0;break; if leap printf %-4d,m ;h++; if h%10 0 printf \n ; leap 1; printf \nThe total is %d,h ; 【程序3】 本身。例如:153是一个“水仙花数”,因为153 1的三次方+5的三次方+3的三次方。1.程序分析:利用for循环控制100-999个数,每个数分解出个位,十位,百位。2.程序源代码:main int i,j,k,n;printf water flowernumber is: ;for n 100;n 1000;n++ i n/100;/*分解出百位*/j n/10%10;/*分解出十位*/k n%10;/*分解出个位*/if i*100+j*10+k i*i*i+j*j*j+k*k*k printf %-5d,n ; printf \n ; 【程序4】90,打印出90 2*3*3*5。
来源:考研论坛 liucheng 2002-12-2 17:22:02
谢谢楼上的贡献!!!!!!!!!
※ 来源:考研论坛 2002-12-2 18:37:49
好帖~~~~~谢谢
来源:考研论坛 liuyd123 2002-12-3 16:08:51
顶
※ 来源:考研论坛 2002-12-4 17:04:42
【程序81】809*?? 800*??+9*??+1 其中??代表的两位数,8*??的结果为两位数,9*??的结果为3位数。求??代表的两位数,及809*??后的结果。1.程序分析:2.程序源代码:output long b,long i printf \n%ld/%ld 809*%ld+%ld,b,i,i,b%i ; main long int a,b,i;a 809;for i 10;i 100;i++ b i*a+1;if b 1000b 100008*i 1009*i 100 output b,i ; 【程序82】1.程序分析: 2.程序源代码:main char *p,s[6];int n;p s;gets p ;n 0;while * p ! \0 n n*8+*p-0;p++; printf %d,n ; 83】0—7所能组成的奇数个数。1.程序分析:2.程序源代码:main long sum 4,s 4;int j;for j 2;j 8;j++ /*j is place of number*/ printf \n%ld,sum ;if j 2 s* 7;elses* 8;sum+ s; printf \nsum %ld,sum ; 84】1.程序分析:2.程序源代码:#include stdio.h#include math.hmain int a,b,c,d;scanf %d,a ;for b 3;b a/2;b+ 2 for c 2;c sqrt b ;c++ if b%c 0 break;if c sqrt b d a-b;elsebreak;for c 2;c sqrt d ;c++ if d%c 0 break;if c sqrt d printf %d %d+%d\n,a,b,d ; 【程序85】9整除1.程序分析:2.程序源代码:main long int m9 9,sum 9;int zi,n1 1,c9 1;scanf
您可能关注的文档
- !secure-vehicular-communication-system-vanet-security-cm1.pdf
- (1小时学会C语言51单片机)C语言入门教程____2016下载.doc
- (Chinese)DB2+DPF-HA.ppt
- (CMR - Hau Lee) Aligning Supply Chain Strategies with Product Uncertainties.pdf
- (Communication+English)通信与信息工程专业英语教程[习题解答].doc
- (CSF) Dilute Sulfuric Acid Pretreatment of Corn Stover in a Pilot-Scale Reactor.pdf
- (CSF) Fractionation of lignocellulosics bysteam-aqueous pretreatments [and discussion.pdf
- (CSF)Pretreatment-Catalyst Effects and the combined severity parameter.pdf
- (ebook) - Physics - Tesla - How To Make Tesla's Coil.pdf
- (麻省理工2016课程)C语言内存管理和C++面向对象编程_lec01.pdf
- 揭秘小数性质_大小比较的奥秘与实用技巧.docx
- AQP-3水通道蛋白在瘢痕疙瘩形成中的作用及机制初探.docx
- 淮南上窑—凤阳山寒武系岩溶发育特征及成因机制.docx
- 十年振兴之路_2008-2025年全球经济危机后的繁荣策略与未来展望.docx
- 益气活血通络法复方通过P2Y12信号通路调控血小板活化的作用及机制.docx
- 国防教育历史长河_文献荟萃与时代核心价值的探索之旅.docx
- 小升初作文成长之路_从构思到精彩呈现的每一步——我的启迪与经验.docx
- 城市更新视角下桐城市历史城区第三空间优化策略研究.docx
- 丹参活性成分丹参酮ⅡA增敏PARP抑制剂奥拉帕尼诱导三阴性乳腺癌细胞凋亡的机制研究.docx
- 国务院办公厅_现代化办公环境与高效设施配置概览.docx
原创力文档

文档评论(0)