[Procedure 51] Title: Learning and uses the bits and &. 1. Program analysis: 0 & 0 = 0; 0 & 1 = 0; 1 & 0 = 0; 1 & 1 = 12. Source code: #include "stdio.h" main () {Int A, b; a = 077; b = a & 3; printf ("/ 40: THE A & B (DECIMAL) IS% D / N", B); B & = 7; Printf ("/ 40: The A & B (DECIMAL) IS% D / N", B);} ============================================================================================================================================================================================================= ============ 【Program 52】 Topic: Learn to use bit or |. 1. Program analysis: 0 | 0 = 0; 0 | 1 = 1; 1 | 0 = 1; 1 | 1 = 1 2. Source code: #include "stdio.h" main () {Int A, b; A = 077; b = a | 3; Printf ("/ 40: THE A & B (DECIMAL) IS% D / N", B); B | = 7; Printf ("/ 40: The A & B (Decimal IS% D / N ", B);} ======================================= ====================================================================================================================================================================================================================】
1. Program analysis: 0 ^ 0 = 0; 0 ^ 1 = 1; 1 ^ 0 = 1; 1 ^ 1 = 02. Source code: #include "stdio.h" main () {Int A, b; A = 077; b = a ^ 3; Printf ("/ 40: the a & b); b); b); b ^ = 7; Printf (" / 40: The a & b (Decimal) IS% D / N ", B);} ======================================= ======================= 【Program 54】 Topic: Take an integer A from 4 to 7 bits from the right end. Program analysis: Can be considered: (1) First move a right 4 bits. (2) Set a number of low 4 digits to 1, the rest of the total is 0. Use ~ (~ 0 << 4) (3) to carry out both the above. 2. Program source code: main () {UNSIGNED A, B, C, D; SCANF ("% O", & a); b = a >> 4; c = ~ (~ 0 << 4); d = B & C PRINTF ("% O / N% O / N", A, D);} =============================== ======================================== 程序 程序 55】 Title: Learn to use the bitwise to reflect ~.
1. Program analysis: ~ 0 = 1; ~ 1 = 0; 2. Source code: #include "stdio.h" main () {Int A, b; a = 234; b = ~ a; printf ("/ 40: THE A'S 1 Complement (Decimal) IX% D / N ", B); A = ~ a; Printf (" / 40: The a's 1 Complement (HexideCIMAL) IS% X / N ", A);} == ============================================================================================================================================================================================================= ========== [Program 56] Topic: Draw, learn Circle painted circular. 1. Program analysis: 2. Source code: / * 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 ) {setColor (8); Circle (310, 250, k); k = k j; j = J 0.3;}} ============================================ =================== 程序 程序 57] Topic: Draw, learn line painting line.
1. Program analysis: 2. Program source code: #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 ) {setColor 5); LINE (X0, Y0, X0, Y1); X0 = X0-5; Y0 = Y0-5; X1 = x1 5; Y1 = Y1 5; J = J 10;} X0 = 263; Y1 = 275; Y0 = 263; for (i = 0; i <= 20; i ) {setColor (5); line (x0, y0, x0, y1); X0 = x0 5; Y0 = Y0 5; Y1 = Y1-5;}} ============================================ =================== 【Procedure 58】 Topic: Draw, learn Rectangle paintings. 1. Program analysis: Use the for loop to control 100-999 numbers, each number is broken down, ten, one hundred.
2. Program source code: #include "graphics.h" main () {Int x0, y0, y1, x1, driver, mod, i; driver = vga; mode = vgahi; INITGRAPH (& Driver, & Mode, "); Setbkcolor (YELLOW); X0 = 263; Y0 = 263; Y1 = 275; x1 = 275; for (i = 0; i <= 18; i ) {setColor (1); Rectangle (X0, Y0, X1, Y1) X0 = x0-5; Y0 = Y0-5; x1 = x1 5; Y1 = Y1 5;} setTextStyle (default_font, horiz_dir, 2); OutTextxy (150, 40, "How beautiful it is!"); Line (130, 60, 480, 60); setColor (2); Circle (269, 269, 137);} ============================== ======================================== 【Program 59】 Title: Draw, integrated example.
1. Program analysis: 2. Source code: # define pai 3.1415926 # Define B 0.809 # include "graphics.h" #include "math.h" main () {INT i, J, K, X0, Y0, X, Y, 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 (); set1fillstyle (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 ) = (2 * pai / 16) * i (2 * pai / 180) * k-1; x = CEIL (x0 48 * cos (a)); y = CEIL (Y0 48 * sin (a) * b); line (x0, y0, x, y);}}}}}} ==== ============================================================================================================================================================================================================= ======== [Program 60] Title: Draw, integrated example.