C語言小程序設(shè)計經(jīng)典100例_第1頁
C語言小程序設(shè)計經(jīng)典100例_第2頁
C語言小程序設(shè)計經(jīng)典100例_第3頁
C語言小程序設(shè)計經(jīng)典100例_第4頁
C語言小程序設(shè)計經(jīng)典100例_第5頁
已閱讀5頁,還剩25頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

1#include"stdio.h"#include"conio.h"inti,j,k;for(i=1;i<5;i++)/*以下為三重循環(huán)*/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)/*如果一個數(shù)的平方根的平方等于該數(shù),這4程序分析:以3月55#include"stdio.h"#include"conio.h"intday,month,year,sum,leap;printf("\npleaseinputyear,month,day\n");switch(month)/*先計算某月以前月份的總天數(shù)*/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;/*再加上某天的天數(shù)*/if(year%400==0||(year%4==0&&year%100!=0))/*判斷是不是閏年*/if(leap==1&&month>2)/*2,總天數(shù)應(yīng)該加一天*/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程序分析 兔子的規(guī)律為數(shù)列#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之間有多少個素數(shù),并輸出所有素數(shù)。#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);/*定位函數(shù)*/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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論