国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

經典c程序100例==51--60

2019-11-17 05:46:55
字體:
來源:轉載
供稿:網友
【程序51】
題目:學習使用按位與 & 。   
1.程序分析:0&0=0; 0&1=0; 1&0=0; 1&1=1
2.程序源代碼:
#include "stdio.h"
main()
{
int a,b;
a=077;
b=a&3;
b&=7;
printf("40: The a & b(decimal) is %d ",b);
}
==============================================================
【程序52】
題目:學習使用按位或 。
1.程序分析:00=0; 01=1; 10=1; 11=1            
2.程序源代碼:
#include "stdio.h"
main()
{
int a,b;
a=077;
b=a3;
printf("40: The a & b(decimal) is %d ",b);
b=7;
printf("40: The a & b(decimal) is %d ",b);
}
==============================================================
【程序53】
題目:學習使用按位異或 ^ 。   
1.程序分析:0^0=0; 0^1=1; 1^0=1; 1^1=0
2.程序源代碼:
#include "stdio.h"
main()
{
int a,b;
a=077;
b=a^3;
printf("40: The a & b(decimal) is %d ",b);
b^=7;
printf("40: The a & b(decimal) is %d ",b);
}
==============================================================
【程序54】
題目:取一個整數a從右端開始的4~7位。
程序分析:可以這樣考慮:
(1)先使a右移4位。
(2)設置一個低4位全為1,其余全為0的數。可用~(~0<<4)
(3)將上面二者進行&運算。
2.程序源代碼:
main()
{
unsigned a,b,c,d;
scanf("%o",&a);
b=a>>4;
c=~(~0<<4);
d=b&c;
printf("%o %o ",a,d);
}
==============================================================
 【程序55】
題目:學習使用按位取反~。   
1.程序分析:~0=1; ~1=0;
2.程序源代碼:
#include "stdio.h"
main()
{
int a,b;
a=234;
b=~a;
printf("40: The a's 1 complement(decimal) is %d ",b);
a=~a;
printf("40: The a's 1 complement(hexidecimal) is %x ",a);
}
==============================================================
【程序56】
題目:畫圖,學用circle畫圓形。   
1.程序分析:
2.程序源代碼:
/*circle*/
#include "graphics.h"
main()
{int driver,mode,i;
float j=1,k=1;
driver=VGA;mode=VGAHI;
initgraph(&driver,&mode,"");
setbkcolor(YELLOW);
for(i=0;i<=25;i++)

}
==============================================================
【程序57】
題目:畫圖,學用line畫直線。
1.程序分析:           
2.程序源代碼:
#include "graphics.h"
main()
{int driver,mode,i;
float x0,y0,y1,x1;
float j=12,k;
driver=VGA;mode=VGAHI;
initgraph(&driver,&mode,"");
setbkcolor(GREEN);
x0=263;y0=263;y1=275;x1=275;
for(i=0;i<=18;i++)

x0=263;y1=275;y0=263;
for(i=0;i<=20;i++)

}
==============================================================
【程序58】
題目:畫圖,學用rectangle畫方形。   
1.程序分析:利用for循環控制100-999個數,每個數分解出個位,十位,百位。
2.程序源代碼:
#include "graphics.h"
main()
{int x0,y0,y1,x1,driver,mode,i;
driver=VGA;mode=VGAHI;
initgraph(&driver,&mode,"");
setbkcolor(YELLOW);
x0=263;y0=263;y1=275;x1=275;
for(i=0;i<=18;i++)

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()
{
int i,j,k,x0,y0,x,y,driver,mode;
float a;
driver=CGA;mode=CGAC0;
initgraph(&driver,&mode,"");
setcolor(3);
setbkcolor(GREEN);
x0=150;y0=100;
circle(x0,y0,10);
circle(x0,y0,20);
circle(x0,y0,50);
for(i=0;i<16;i++)
{
 a=(2*PAI/16)*i;
 x=ceil(x0+48*cos(a));
 y=ceil(y0+48*sin(a)*B);
 setcolor(2); line(x0,y0,x,y);}
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++)
{
 setcolor(3);
 for(i=0;i<=16;i++)
 {
  a=(2*PAI/16)*i+(2*PAI/180)*k;
  x=ceil(x0+48*cos(a));
  y=ceil(y0+48+sin(a)*B);
  setcolor(2); line(x0,y0,x,y);
 }
 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()
{
int driver,mode,error;
int x1,y1;
int x2,y2;
int dx1,dy1,dx2,dy2,i=1;
int count=0;
int color=0;
driver=VGA;
mode=VGAHI;
initgraph(&driver,&mode,"");
x1=x2=y1=y2=10;
dx1=dy1=2;
dx2=dy2=3;
while(!kbhit())

}
closegraph();
}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 成都市| 北京市| 汤原县| 璧山县| 丰宁| 云龙县| 思南县| 盐源县| 禄丰县| 祁门县| 惠水县| 监利县| 铁力市| 雅安市| 南通市| 康马县| 巩留县| 瑞安市| 临邑县| 临泉县| 佳木斯市| 揭阳市| 旅游| 永泰县| 永城市| 丰城市| 浪卡子县| 商南县| 兖州市| 曲水县| 滕州市| 林西县| 北川| 集贤县| 九江县| 岚皋县| 阜康市| 政和县| 电白县| 德庆县| 阿鲁科尔沁旗|