【正文】
void main(){int i。i3。}==============================================================【程序42】 題目:學習使用auto定義變量的用法: ?。篿nclude main(){int i,num?!or (i=0。i++) { printf(\40: The num equal %d \n,num)?! auto int num=1?! um++?! 。海篿nclude main(){int i,num。for(i=0。i++){printf(\40: The num equal %d \n,num)。{static int num=1。num++。::include int a,b,c。a=3。}void main(){ a=b=4。printf(The value of c is equal to %d\n,c)。::void main(){register int i。for(i=1。i++)tmp+=i。}==============================================================【程序46】題目:宏define命令練習(1) ::include define TRUE 1define FALSE 0define SQ(x) (x)*(x)void main(){int num。printf(\40: Program will stop if input value less than 50.\n)。scanf(%d,amp。printf(\40:The square for this number is %d \n,SQ(num))。else again=FALSE。\ t=a。\ b=t。int y=20。 y=%d\n,x,y)。printf(x=%d。}==============================================================【程序48】題目:宏define命令練習(3) ?。海篸efine LAG define SMA define EQ ==include void main(){ int i=10。if(i LAG j)printf(\40: %d larger than %d \n,i,j)。else if(i SMA j)printf(\40:%d smaller than %d \n,i,j)。}==============================================================【程序49】題目:if ifdef和ifndef的綜合應用。ifdef MAXprintf(\40: The larger one is %d\n,MAXIMUM(a,b))。endififndef MINprintf(\40: The lower one is %d\n,MINIMUM(a,b))。endifundef MAXifdef MAXprintf(\40: The larger one is %d\n,MAXIMUM(a,b))。endifdefine MINifndef MINprintf(\40: The lower one is %d\n,MINIMUM(a,b))。endif}==============================================================【程序50】題目:include 的應用練習 :: 文件如下:define LAG define SMA define EQ ==include /*,*/include void main(){ int i=10。if(i LAG j)printf(\40: %d larger than %d \n,i,j)。else if(i SMA j)printf(\40:%d smaller than %d \n,i,j)。}經(jīng)典c程序100例==5160【程序51】題目:學習使用按位與 amp。 ?。?amp。 0amp。 1amp。 1amp。a=077。3。 b(decimal) is %d \n,b)。=7。 b(decimal) is %d \n,b)。:0|0=0。 1|0=1。a=077。printf(\40: The a amp。b|=7。 b(decimal) is %d \n,b)?! 。?^0=0。 1^0=1。a=077。printf(\40: The a amp。b^=7。 b(decimal) is %d \n,b)。程序分析:可以這樣考慮: (1)先使a右移4位。可用~(~04)(3)將上面二者進行amp。:main(){unsigned a,b,c,d。a)。c=~(~04)。c。}==============================================================【程序55】題目:學習使用按位取反~。 ~1=0。a=234。printf(\40: The a39。a=~a。s 1 plement(hexidecimal) is %x \n,a)?! 。海?*circle*/include main(){int driver,mode,i。driver=VGA。initgraph(amp。mode,)。for(i=0。i++){setcolor(8)。k=k+j。}} ==============================================================【程序57】題目:畫圖,學用line畫直線。float x0,y0,y1,x1。driver=VGA。initgraph(amp。mode,)。x0=263。y1=275。for(i=0。i++){setcolor(5)。x0=x05。x1=x1+5。j=j+10。y1=275。for(i=0。i++){setcolor(5)。x0=x0+5。y1=y15?! 。豪胒or循環(huán)控制100999個數(shù),每個數(shù)分解出個位,十位,百位。driver=VGA。initgraph(amp。mode,)。x0=263。y1=275。for(i=0。i++){setcolor(1)。x0=x05。x1=x1+5。}settextstyle(DEFAULT_FONT,HORIZ_DIR,2)。line(130,60,480,60)。circle(269,269,137)。:: define PAI define B include include main(){int i,j,k,x0,y0,x,y,driver,mode。driver=CGA。initgraph(amp。mode,)。setbkcolor(GREEN)。y0=100。circle(x0,y0,20)。for(i=0。i++){ a=(2*PAI/16)*i?!=ceil(y0+48*sin(a)*B)。 line(x0,y0,x,y)。circle(x0,y0,60)。outtextxy(10,170,press a key)。setfillstyle(HATCH_FILL,YELLOW)。getch()。k=500?!or(i=0。i++) { a=(2*PAI/16)*i+(2*PAI/180)*k?! =ceil(y0+48+sin(a)*B)。 line(x0,y0,x,y)。j=50?! =ceil(x0+48*cos(a))?! ine(x0,y0,x,y)。}==============================================================【程序60】題目:畫圖,綜合例子。int x1,y1。int dx1,dy1,dx2,dy2,i=1。int color=0。mode=VGAHI。driver,amp。x1=x2=y1=y2=10。dx2=dy2=3?!1+=dx1?!2+=dx2?!f(x1=LEFT||x1=RIGHT) dx1=dx1?!f(x2=LEFT||x2=RIGHT) dx2=dx2。 if(++countLINES) { setcolor(color)?!}closegraph()。int a[10][10]。for(i=0。i++) {a[i][0]=1。}for(i=2。i++) for(j=1。j++) a[i][j]=a[i1][j1]+a[i1][j]。i10。j=i。 printf(\n)。: :include include main(){int i,j,driver=VGA,mode=VGAHI。driver,amp。setbkcolor(YELLOW)。i=230。j=230。for(j=50。j+=20) for(i=50。i++) putpixel(i,j,1)。int num=20,i。initgraph(amp。mode,)。bottom=y30。inum。top=5。}getch()。::include include include main(){int driver=VGA,mode=VGAHI。int left=20,right=50。driver,amp。for(i=0。i++){ellipse(250,250,0,360,right,left)。rectangle(202*i,202*i,10*(i+2),10*(i+2))。left+=5。}getch()。 ?。海篿nclude include include include include include include define MAXPTS 15define PI struct PTS {int x,y。double AspectRatio=。struct PTS points[MAXPTS]。int radius, angle, step。printf( MoveTo / LineTo Demonstration )。vp )。w = 。 /* Determine the center of circle */ycenter = h / 2。step = 360 / MAXPTS。 /* Begin at zero degrees */for( i=0 。 ++i ){ /* Determine circle intercepts */rads = (double)angle * PI / 。points[i].y = ycenter (int)( sin(rads) * radius * AspectRatio )。 /* Move to next increment */}circle( xcenter, ycenter, radius )。 iMAXPTS 。 jMAXPTS 。 /* Move to beginning of cord */lineto(points[j].x, points[j].y)。driver=CGA。initgraph(amp。mode,)。setbkcolor(GREEN)。}==============================================================【程序66】題目:輸入3個數(shù)a,b,c,按大小順序輸出。:/*pointer*/main(){int n1,n2,n3。printf(please input 3 number:n1,n2,n3:)。n1,amp。n3)。n1。n2。n3。if(n1n3) swap(pointer1,pointer3)。printf(the sorted numbers are:%d,%d,%d\n,n1,n2,n3)。{int p。*p1=*p2。}==============================================================【程序67】題目:輸入數(shù)組,最大的與第一個元素交換,最小的與最后一個元素交換,輸出數(shù)組?! 。簃ain(){int number[10]。max_min(number)。}input(number)int number[10]。for