Scattered knowledge points:
1, non-formatted input and output: GetChar (), Putchar ()
2. Format input/output: scanf (), printf ()
3. String input and output: gets () or scanf (), puts (), or printf ().
Difference: the Get () function takes the newline character or the file terminator EOF as the end flag of the input, so the input string is allowed to contain spaces or tabs;
The scanf () function takes a space, tab, newline, and file Terminator EOF as the end flag for the input, so the characters are not allowed in the input string.
The puts () function wraps after the string is displayed.
The printf () function does not break lines.
4,%f that the position should enter a real value
5.%s indicates that this position should be entered as a string
6. The purpose of the break statement is to terminate the statement sequence that executes the subsequent branch.
7, the Continue statement can only be applied in the loop statement, its role is: to force the execution of this cycle, to go to perform the next cycle.
8, for two number of least common multiple: First compare size (size sort), after using the method of greatest common divisor, find out the dividend/divisor = quotient ... The remainder is then divided by the remainder by dividing it until the remainder is 0, then the product of two numbers is divided by the greatest common divisor.
9, one-dimensional arrays: Once the variable is defined, the system will allocate a contiguous amount of storage space for each array variable.
10, 32-bit operating system, type int is 4 bytes.
11, int vote[10]={0} indicates that each element is given an initial value of 0.
12. Use keyboard input to assign values to each element in the array:
int i; int score[]; for 0 ; i++) { scanf ("%f", &score[i]);}
13. Determine if the alphabet is English
1) (' A ' <=ch && ch <= ' Z ') | | (' a<=ch && ch <= ' z ')
2) Isalpha (c) c is a character, and the header file is <ctype.h>. When C is the English letter, the function returns not 0; otherwise the function returns 0.
14, sorting problem--Choose the sorting method:
Program One:
Function Description: Enter an integer n to print out a equilateral triangle consisting of n characters asterisk "*".
#include <stdio.h>Main () {intN, I, J; printf ("Please enter the side of the triangle:"); scanf_s ("%d", &N); for(i =1; I <= N; i++){ for(j =1; J <= N-i; J + +) {Putchar (' '); } for(j =1; J <= I; J + +) {Putchar ('*'); if(J! =i) {Putchar ('_'); }} putchar ('\ n'); }}
Results:
Program Two:
Function Description: Enter lines of text, counting the number of lines, words, and characters.
#include <stdio.h> #include <stdlib.h> #include <string.h> #pragma warning (disable:4996) #define IN 1/ * Inside a word */#define OUT 0/* outside a word *//* count lines, words, and characters in input */main () {int C, NL, NW, NC, state;state = OUT;NL = NW = NC = 0;while ((c = GetChar ())! = ' END ') {++nc;if (c = = ' \ n ') ++nl;if (c = = ' | | c = = ' \ n ') || c = = ' \ t ') state = Out;else if (state = = off) {state = IN;++NW;}} printf ("%d%d%d\n", NL, NW, NC);}
Program Three:
Function Description: Output monthly calendar of the current month.
#include <stdio.h>Main () {intN, I, J; scanf_s ("%d", &N); if(n = =7) n=0; ElseN=N; printf ("Sun Mon Tue Wed Tur Fri sat\n"); for(i =1; I <= N; i++) {printf ("%4c",' '); } for(j =1; J <= -; J + +){ if((j + N)%7==0) {printf ("%4d", J); printf ("\ n"); } Else{printf ("%4d", J); } } return 0;}
Results:
Program Four:
Function Description: Enter a positive integer from the keyboard to output all the factors of this integer.
C Language Programming Case Tutorial (2nd edition) Code notes