Classic C language procedure 100 cases (81-90) -------------- Transfer from C Language Classics Forum

xiaoxiao2021-03-06  46

[Program 81] Title: 809 * ?? = 800 * ?? 9 * ?? 1 Among them, the two digits of the representative, 8 * ?? the result of two digits, 9 * ?? the result of 3 Bit number. Request for the two digits of the representative, and the result of 809 * ??. 1. Program analysis: 2. Source code: OUTPUT (long b, long i) {printf ("/ n% ld /% ld = 809 *% ld % ld", B, I, I, b% i); } main () {long Int A, B, I; A = 809; for (i = 10; i <100; i ) {b = i * a 1; if (b> = 1000 && b <= 10000 && 8 * i < 100 && 9 * i> = 100) Output (b, i);}} ================================== ============================ 【Program 82】 Title: Octa conversion to decimal 1. Program analysis: 2. Program source code: main () {char * p, s [6]; int N; p = S; Gets (p); n = 0; while (* (p)! = '/ 0') {n = n * 8 * P -'0 '; p ;} Printf ("% d", n);} =============================== ======================================= 【Program 83】 Title: Seeking the odd number of odd numbers that can be composed of 0-7.

1. Program analysis: 2. Source code: main () {long sum = 4, s = 4; int J; for (j = 2; j <= 8; j ) / * j is place of number * / { Printf ("/ n% ld", sum); if (j <= 2) s * = 7; else * = 8; SUM = S;} Printf ("/ nsum =% ld", sum);} == ============================================================================================================================================================================================================= ========== [Program 84] Title: A number of even numbers can be represented as the sum of two prime numbers.

1. Program analysis: 2. Source code: #include "stdio.h" #include "math.h" main () {Int A, B, C, D; scanf ("% d", & a); for B = 3; B <= a / 2; b = 2) {for (c = 2; c <= SQRT (B); C ) IF (b% c == 0) Break; if (c> sqrt (B )) D = ab; elsebreak; for (c = 2; c <= SQRT (D); C ) IF (D% c == 0) Break; if (c> SQRT (D)) Printf ("% D = % D % D / N ", A, B, D);}} =================================== ============================= 【Program 85】 Title: Judgment a number of numbers can be taken 9 整 1. Program analysis: 2 . Source code: main () {long int m9 = 9, sum = 9; int zi, n1 = 1, c9 = 1; scanf ("% d", & zi); while (n1! = 0) {IF ! (sum% zi)) N1 = 0; ELSE {m9 = m9 * 10; sum = SUM M9; C9 ;}} printf ("% ld, can be divided by% D /" 9 / ", SUM, C9);} ============================================== ================ 【Program 86】 Title: Two string connections 1. Program analysis: 2. Source code: #include "stdio.h" main () { Char a [] = "acegikm"; char b [] = "bdfhjlnpq"; char C [80], * p; int i = 0, j = 0, k = 0; while (a [i]! = '/ 0 '&& B [J]! =' / 0 ') {IF (a [i] {c [k] = a [i]; i ;} elsec [k] = b [j ]; k ;} C [K ] = '/ 0'; if (a [i] == '/ 0') P = B J; ELSEP = A I;

STRCAT (C, P); PUTS (c);} ======================================= ========================= 【Program 87】 Title: Answer results (Structure variable delivery) 1. Program analysis: 2. Program source code: #include "stdio.h" struct student {int x; char C;} a; main () {ax = 3; ac = 'a'; f (a); printf ("% D,% C", AX, AC);} f (struct student b) {bx = 20; bc = 'y';} ============================ =================================== 程序 程序 88] Topic: 7 digits (1-50) The integer value, each reads a value, the program prints the number of this value. 1. Program analysis: 2. Source code: main () {INT i, a, n = 1; while (n <= 7) {DO {scanf ("% d", & a);} while (a <1 || a> 50); for (i = 1; i <= a; i ) printf ("*"); printf ("/ n"); n ;} getCH ();} ======= ============================================================================================================================================================================================================= ===== [Program 89] Topic: A company uses public telephone delivery data, data is an integer, encrypted in the delivery process, encrypted rules are as follows: Each number plus 5, then use and Instead of this number, the first bit and the fourth interchange are exchanged, and the second bit and the third one are exchanged.

转载请注明原文地址:https://www.9cbs.com/read-79924.html

New Post(0)