C语言小程序设计经典100例_第1页
C语言小程序设计经典100例_第2页
C语言小程序设计经典100例_第3页
C语言小程序设计经典100例_第4页
C语言小程序设计经典100例_第5页
已阅读5页,还剩25页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1#include"stdio.h"#include"conio.h"inti,j,k;for(i=1;i<5;i++)/*以下为三重循环*/forif(i!=k&&i!=j&&j!=k)/*i、j、k*/2601.5%,高于#include"stdio.h"#include"conio.h"longintintbonus1,bonus2,bonus4,bonus6,bonus10,bonus;bonus1=100000*0.1;elseif(i<=200000)elseif(i<=400000)elseif(i<=600000)elseif(i<=1000000)3#include"math.h"#include"stdio.h"#include"conio.h"longintforx=sqrt(i+100);/*x100*/y=sqrt(i+268);/*y168*/if(x*x==i+100&&y*y==i+268)/*如果一个数的平方根的平方等于该数,这4程序分析:以3月55#include"stdio.h"#include"conio.h"intday,month,year,sum,leap;printf("\npleaseinputyear,month,day\n");switch(month)/*先计算某月以前月份的总天数*/case1:sum=0;break;case2:sum=31;break;case3:sum=59;break;case4:sum=90;break;case5:sum=120;break;case6:sum=151;break;case7:sum=181;break;case8:sum=212;break;case9:sum=243;break;case10:sum=273;break;case11:sum=304;break;casedefault:printf("datasum=sum+day;/*再加上某天的天数*/if(year%400==0||(year%4==0&&year%100!=0))/*判断是不是闰年*/if(leap==1&&month>2)/*2,总天数应该加一天*/printf("Itisthe%dthday.",sum);5x,y,z,xx与yx>y则将x与y然后再用x与zx>zx与zx#include"stdio.h"#include"conio.h"intx,y,z,t;if(x>y){t=x;x=y;y=t;}/*x,y*/{t=z;z=x;x=t;}/*x,z*/{t=y;y=z;z=t;}/*z,y*/printf("smalltobig:%d%d%d\n",x,y,z);6题目:用*号输出字母C的图案。#include"stdio.h"#include"conio.h"printf("HelloC-world!\n");printf("****\n");printf("printf("*\n");printf("****\n");7c,VeryBeautiful!1.256#include"stdio.h"#includechara=176,b=219;89*9程序分析:分行与列考虑,共9行9,i,j#include"stdio.h"#include"conio.h"inti,j,result;forprintf("%d*%d=%-3d",i,j,result);/*-3d3printf("\n");/*每一行后换行9#include"stdio.h"#include"conio.h"inti,j; 10#include"stdio.h"#include"conio.h"intprintf("\1\1\n");/*输出两个笑脸*/c100==11--20c100==11--11程序分析 兔子的规律为数列#include"stdio.h"#include"conio.h"longf1,f2;inti;printf("%12ldif(i%2==0)printf("\n");/*控制输出,每行四个*/f1=f1+f2;/*前两个月加起来赋值给第三个月*/f2=f1+f2;/*前两个月加起来赋值给第三个月*/12题目:判断101-200之间有多少个素数,并输出所有素数。#include"stdio.h"#include"conio.h"#include"math.h"intm,i,k,h=0,leap=1;printf("\nThetotalis%d",h);13方+3for100-999#include"stdio.h"#include"conio.h"intprintf("'waterflower'numberis:");printf("%-1490,90=2*3*3*5n,n,/*zhengintisdividedyinshu*/#include"stdio.h"#include"conio.h"intprintf("\npleaseinputanumber:\n");1560-89B60C程序分析:(a>b)?a:b#include"stdio.h"#include"conio.h"intscore;charprintf("pleaseinputascore\n");printf("%dbelongsto%c",score,grade);16#include"stdio.h"#includeintprintf("pleaseinputtwonumbers:\n");while(b!=0)/*利用辗除法,直到b为0*/17while#include"stdio.h"#include"conio.h"charintletters=0,space=0,digit=0,others=0;printf("pleaseinputsomecharacters\n");elseif(c=='')elseif(c>='0'&&c<='9')printf("allinall:char=%dspace=%ddigit=%dothers=%d\n",letters,18#include"stdio.h"#include"conio.h"inta,n,count=1;longintsn=0,tn=0;printf("pleaseinputaandn\n");191000#include"stdio.h"#include"conio.h"staticintinti,j,n,s;n=-printf("%disawanshu",j);20#include"stdio.h"#include"stdio.h"floatsn=100.0,hn=sn/2;intn;hn=hn/2;/*n*/printf("thetotalofroadis%f\n",sn);printf("thetenthis%fmeter\n",hn);c100==21--c100==21--21#include"stdio.h"#include"conio.h"intday,x1,x2;day--printf("thetotalis%d\n",x1);22#include#include"conio.h"chari,j,k;/*ia,jb,kc*/printf("orderisa--%c\tb--%c\tc--23题目:打印出如下图案(菱形#include"stdio.h"#include"conio.h"inti,j,k;printf("");printf("");2420#include"stdio.h"#include"conio.h"intn,t,number=20;floata=2,b=1,s=0;t=a;a=a+b;b=t;/*tprintf("sumis%9.6f\n",s);251+2!+3!+...+20!#include"stdio.h"#include"conio.h"floatn,s=0,t=1;26题目:利用递归方法求5!。#include"stdio.h"#include"conio.h"intintfact();intfact(j)intj;intsum;returnsum;27#include"stdio.h"#include"conio.h"intvoidpalin(intn);voidpalin(n)intn;charnext;2810#include"stdio.h"#include"conio.h"intintc;if(n==1)c=10;elsec=age(n-1)+2;29002#include"stdio.h"#include"conio.h"main()longif(a!=0)printf("thereare5,%ld%ld%ld%ld%ld\n",e,d,c,b,a);elseif(b!=0)printf("thereare4,%ld%ld%ld%ld\n",e,d,c,b);elseif(c!=0)printf("thereare3,%ld%ld%ld\n",e,d,c);elseif(d!=0)printf("thereare2,%ld%ld\n",e,d);elseif(e!=0)printf("thereare1,%ld\n",e);3029#include"stdio.h"#include"conio.h"main()longge,shi,qian,wan,x;printf("thisnumberisahuiwen\n");printf("thisnumberisnotahuiwen\n");c100==31--c100==31--31if#include"stdio.h"#include"conio.h"voidmain()charprintf("pleaseinputthefirstletterofsomeday\n");while((letter=getch())!='Y')/*Yswitchcase'S':printf("pleaseinputsecondletter\n");elseif((letter=getch())=='u')elseprintf("dataerror\n");case'F':printf("friday\n");break;casecase'T':printf("pleaseinputsecondletter\n");elseif((letter=getch())=='h')elseprintf("dataerror\n");casedefault:printf("data32题目:PressanykeytochangecolordoyouwanttotryitPleasehurry#include"conio.h"#include"stdio.h"voidmain(void)intfor(color=0;color<8;cprintf("Thisiscolor%d\r\n",color);cprintf("Pressanykeytocontinue\r\n");33#include"conio.h"#include"stdio.h"voidmain(void)gotoxy(1,5);/*定位函数*/cprintf("Outputatrow5column1\n");gotoxy(20,cprintf("Outputatrow10column20\n");34#include"stdio.h"#include"conio.h"voidhello_world(void)printf("Hello,voidintfor(counter1;counter3;counter++)void35#include"stdio.h"#include"conio.h"voidmain(void)intfor(color=1;color<16;cprintf("Thisiscolor%d\r\n",color);textcolor(128+15);cprintf("Thisisblinking\r\n");362.#include"stdio.h"#include"math.h"#defineN101inti,j,line,a[N];for(i=2;i<N;i++)a=i;3710#include"stdio.h"#include"conio.h"#defineN10int/*inputprintf("pleaseinputtennum:\n");/*sorttennum*//*outputdata*/printf("Aftersorted\n");383*3fora#include"stdio.h"#include/*TCstaticvoiddummyfloat(float*x){floaty;dummyfloat(&y);}floata[3][3],sum=0;inti,j;printf("pleaseinputrectangleelement:\n");printf("duijiaoxianheis%6.2f",sum);39#include"stdio.h"#include"conio.h"intinttemp1,temp2,number,end,i,j;printf("originalarrayis:\n");printf("insertanewnumber:");40#include"stdio.h"#include"conio.h"#defineN5inta[N]={9,6,5,4,1},i,temp;printf("\noriginalarray:\n");a[N-i-printf("\nsortedarray:\n");c100==41--c100==41--41#include"stdio.h"#include"conio.h"intstaticintstatic_var=0;printf("\40:varequal%d\n",var);printf("\40:staticvarequal%d\n",static_var);voidinti;42#include"stdio.h"#include"conio.h"inti,num;printf("\40:Thenumequal%d\n",num);autointprintf("\40:Theinternalblocknumequal%d\n",num);43#include"stdio.h"#include"conio.h"inti,num;printf("\40:Thenumequal%d\n",num);staticintprintf("\40:Theinternalblocknumequal%d\n",num);44#include"stdio.h"#include"conio.h"inta,b,c;voidinta;voidprintf("Thevalueofcisequalto%d\n",c);45#include"stdio.h"#include"conio.h"voidmain()registerinti;inttmp=0;printf("Thesumis%d\n",tmp);46#include"stdio.h"#include"conio.h"#defineTRUE1#defineFALSE0#defineSQ(x)(x)*(x)voidmain()intintprintf("\40:Programwillstopifinputvaluelessthan50.\n");printf("\40:Pleaseinputnumber==>");printf("\40:Thesquareforthisnumberis%d\n",SQ(num));47#include"stdio.h"#include#defineexchange(a,b){\intt;\voidintx=10;intprintf("x=%d;y=%d\n",x,y);printf("x=%d;y=%d\n",x,y);48#defineLAG>#defineSMA<#defineEQ==#include

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论