Today wrote several reference code for your reference
Bosses don't spray
Enter a four-digit, reverse output
# include & lt; stdio.h>
Int main ()
{
Int a, b, c, d, num.
Printf (" please enter a four-digit: ");
The scanf (" % d ", & amp; Num);
Printf (" input four digits for: % d \ n ", num);
A=num/1000;
B=num % 1000/100;
C=100/10 num % 1000%;
D=10 num % 1000% 100%;
Printf (" reverse output is: % d % d % d % d ", d, c, b, a);
return 0;
}
Input rectangle width, calculate the perimeter and area of
# include
Int main ()
{
Float a, b, S, L;
Printf (" please enter a long rectangular: ");
The scanf (" % f ", & amp; A);
Printf (" please enter the rectangular wide: ");
The scanf (" % f ", & amp; b);
S=a * b;
L=2 * (a + b);
Printf (" the area of the rectangle area=% 2 f \ n=% the perimeter of a rectangular circumference. 2 f \ n ", S, L);
Printf (" the area of the rectangular area and the perimeter of rectangle is % 2 f, %, 2 f \ n ", S, L);
return 0;
}
To determine whether a password correctly
# include & lt; stdio.h>
Int main ()
{
Long int passworld.
Printf (" please enter the password: ");
The scanf (" % d ", & amp; Passworld);
If (passworld==123456)
Printf (" password right!" );
The else
Printf (" password error!" );
return 0;
}
Judge coordinate quadrant
# include & lt; stdio.h>
Int main ()
{
Float x, y;
Printf (" please enter the abscissa: ");
The scanf (" % f ", & amp; x);
Printf (" please enter the ordinate: ");
The scanf (" % f ", & amp; y);
If (x> 0 & amp; & Y> 0)
Printf (" this point in the first quadrant ");
The else
If (x> 0 & amp; & Y<0)
Printf (" that point in the fourth quadrant ");
The else
If (x<0 & amp; & Y> 0)
Printf (" that point in the second quadrant ");
The else
Printf (" that point in the third quadrant ");
return 0;
}
Number three sorting, calculating average
# include & lt; stdio.h>
Int main ()
{
Double a, b, c, Max, min, p;
Printf (" please input the first number ");
Lf the scanf (" % ", & amp; A);
Printf (" please enter the second number ");
Lf the scanf (" % ", & amp; b);
Printf (" please enter the number 3 ");
Lf the scanf (" % ", & amp; C);
if(a> B)
{
Max=a;
Min=b;
}
The else
{
Max=b;
Min=a;
}
If (max
If (min> C) min=c;
P=(a + b + c)/3;
Printf (" maximum value for: % lf \ n minimum value is: % lf \ n mean is: % lf ", Max, min, p);
return 0;
}
CodePudding user response:
Encourage encouragement! Clap clapCodePudding user response:
1.
C num %=100/10;
D=num % 10;
2. Nope
3.
If (x> 0 & amp; & Y> 0 {
} else if (y> 0 {
} else if (x> 0 {
} else {
}
4.
Max=a;
Min=a;
If (maxThe else min=b;
If (maxElse if (min> C) min=c;