C 練習例項51 60

2021-08-10 22:14:37 字數 2286 閱讀 6805

51.題目:學習使用按位與 &。

程式分析:0&0=0; 0&1=0; 1&0=0; 1&1=1 。
#include 

int main()

52.題目:學習使用按位或 |。

程式分析:0|0=0; 0|1=1; 1|0=1; 1|1=1 。
#include

int main()

53.題目:學習使用按位異或 ^。

程式分析:0^0=0; 0^1=1; 1^0=1; 1^1=0 。
#include 

int main()

54.題目:取乙個整數a從右端開始的4~7位。

程式分析:可以這樣考慮:

(1)先使a右移4位。

(2)設定乙個低4位全為1,其餘全為0的數。可用~(~0<<4)

(3)將上面二者進行&運算。

#include 

int main()

55.題目:學習使用按位取反~。

程式分析:~0=1; ~1=0;
#include 

int main()

56.題目:畫圖,學用circle畫圓形。

#include 

中是不能執行的,要在turbo2.0/3.0中

int main()

return

0;

}

57.題目:畫圖,學用line畫直線(在tc中實現)。

#include "graphics.h"

intmain()

}

58.題目:學用rectangle畫方形。(在tc中實現)。

#include "graphics.h"

intmain()

settextstyle(default_font,horiz_dir,2);

outtextxy(150,40,"how

beautiful

itis!");

line(130,60,480,60);

setcolor(2);

circle(269,269,137);

}

59.題目:畫圖,綜合例子。(在tc中實現)。

# define pai 3.1415926

# define b 0.809

# include "graphics.h"

#include "math.h"

int main()

setcolor(3);circle(x

0,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.題目:畫圖,綜合例子2。(在tc中實現)。

#include "graphics.h"

#define left 0

#define top 0

#define right 639

#define bottom 479

#define lines 400

#define maxcolor 15

int main()

}closegraph();

}

C 練習例項41 50

41.題目 學習static定義靜態變數的用法。include int main void fun 42.題目 學習使用auto定義變數的用法。include int main return 0 43.題目 學習使用static的另一用法。include int main return 0 44.題...

C語言例項練習

最近撿起了很久以前的c語言,把一些看到敲下練習的例項記錄如下 有1 2 3 4個數字,能組成多少個互不相同且無重複數字的三位數?都是多少?void test1 int num printf count is d n count 乙個整數,它加上100後是乙個完全平方數,再加上168又是乙個完全平方數...

opencv例項練習

利用滑鼠畫矩形或者線段 import cv2 as cv import numpy as np drawing false 如果 mode為true繪製矩形。按下 m 變成繪製曲線。預設是false 滑鼠按下是true mode true ix,iy 1,1 def draw circle even...