經典c語言程式設計100例51-60
【程式51】
題目:學習使用按位與 & 。
1.程式分析:0&0=0; 0&1=0; 1&0=0; 1&1=1
2.程式源**:
#include "stdio.h"
main()
【程式52】
題目:學習使用按位或 | 。
1.程式分析:0|0=0; 0|1=1; 1|0=1; 1|1=1
2.程式源**:
#include "stdio.h"
main()
【程式53】
題目:學習使用按位異或 ^ 。
1.程式分析:0^0=0; 0^1=1; 1^0=1; 1^1=0
2.程式源**:
#include "stdio.h"
main()
【程式54】
題目:取乙個整數a從右端開始的4~7位。
程式分析:可以這樣考慮:
(1)先使a右移4位。
(2)設定乙個低4位全為1,其餘全為0的數。可用~(~0<<4)
(3)將上面二者進行&運算。
2.程式源**:
main()
【程式55】
題目:學習使用按位取反~。
1.程式分析:~0=1; ~1=0;
2.程式源**:
#include "stdio.h"
main()
【程式56】
題目:畫圖,學用circle畫圓形。
1.程式分析:
2.程式源**:
/*circle*/
#include "graphics.h"
main()
}【程式57】
題目:畫圖,學用line畫直線。
1.程式分析
2.程式源**:
#include "graphics.h"
main()
x0=263;y1=275;y0=263;
for(i=0;i<=20;i++)
}【程式58】
題目:畫圖,學用rectangle畫方形。
1.程式分析:利用for迴圈控制100-999個數,每個數分解出個位,十位,百位。
2.程式源**:
#include "graphics.h"
main()
settextstyle(default_font,horiz_dir,2);
outtextxy(150,40,"how beautiful it is!");
line(130,60,480,60);
setcolor(2);
circle(269,269,137);
}【程式59】
題目:畫圖,綜合例子。
1.程式分析:
2.程式源**:
# define pai 3.1415926
# define b 0.809
# include "graphics.h"
#include "math.h"
main()
setcolor(3);circle(x0,y0,60);
/* make 0 time normal size letters */
settextstyle(default_font,horiz_dir,0);
outtextxy(10,170,"press a key");
getch();
setfillstyle(hatch_fill,yellow);
floodfill(202,100,white);
getch();
for(k=0;k<=500;k++)
for(j=1;j<=50;j++) }
restorecrtmode();
}【程式60】
題目:畫圖,綜合例子。
1.程式分析:
2.程式源**:
#include "graphics.h"
#define left 0
#define top 0
#define right 639
#define bottom 479
#define lines 400
#define maxcolor 15
main()
}closegraph();}
經典c語言程式100例
經典c語言程式設計100例81 90 程式81 題目 809 800 9 1 其中?代表的兩位數,8 的結果為兩位數,9 的結果為3位數。求?代表的兩位數,及809 後的結果。1.程式分析 2.程式源 output long b,long i main 程式82 題目 八進位制轉換為十進位制 1.程...
C語言經典100例
程式1 題目 有1 2 3 4個數字,能組成多少個互不相同且無重複數字的三位數?都是多少?1.程式分析 可填在百位 十位 個位的數字都是1 2 3 4。組成所有的排列後再去掉不滿足條件的排列。2.程式源 main 程式2 題目 企業發放的獎金根據利潤提成。利潤 i 低於或等於10萬元時,獎金可提10...
經典c程式100例
經典c程式100例 81 90 程式81 題目 809 800 9 1 其中?代表的兩位數,8 的結果為兩位數,9 的結果為3位數。求?代表的兩位數,及809 後的結果。1.程式分析 2.程式源 output long b,long i main 程式82 題目 八進位制轉換為十進位制 1.程式分析...