(C syntax question 10) separate natural numbers, Natural Number of grammar
Knowledge point:
/%.
Content: A three-digit natural number, which separates its hundreds, ten digits from its single digit
Input description:
A three-digit integer in a row
Output description:
A row contains three numbers separated by spaces. They are hundreds of 10 digits.
Input example:
256
Output example:
2 5 6
#include <stdio.h>int main(){ int a; scanf("%d",&a); printf("%d %d %d\n",a/100,a/10%10,a%10); return 0;}
100 sets of computer second-level C language (c) machine fill in blank questions and correct questions
Nankai Level 2 C language machine 100 questions
1. Correct question 1
The function of the given program is to read an integer (2 <= k "= 10000", print all its quality factors (all the factors with prime numbers ). For example, if an integer of 2310 is input, 2, 3, 5, 7, and 11 are output.
Correct the errors in the program so that the program can produce the correct results.
Note: Do not change multiple main functions, add or delete rows, or change the program structure!
Test procedure:
# Include <conio. h>
# Include <stdio. h>
*******************************
IsPrime (int n); ------ remove the semicolon
{Int I, m;
M = 1;
For (I = 2; I <n; I ++)
******************************
If! (N % I) ------ if (! (N % I ))
{M = 0; break ;}
Return (m );
}
Main ()
{Int j, k;
Clrscr ();
Printf ("nPlease enter an integer number between 2 and 10000:"); scanf ("% d", & k );
Printf ("nnThe prime factor (s) of % d is (are):", k );
For (j = 2; j <= k; j ++)
If ((! (K % j) & (IsPrime (j) printf ("n % 4d", j );
Printf ("n ");
)
2. Programming Question 1
The score of m Individual is stored in the score array. Compile the function fun. The function is to use the number of persons below the average score as the function value row, place the scores lower than the average score in the array indicated by below.
For example, if the data in the score array is 10, 20, 30, 40, 50, 60, 70, 80, or 90, the number of people returned by the function should be 4, data in below should be 10, 20, 30, and 40.
Note: Some source programs are as follows.
Do not modify the main function and any content in other functions. Fill in the prepared statements only in the curly brackets of function fun.
Test procedure:
# Include <conio. h>
# Include <stdio. h>
# Include <string. h>
Int fun (int score [], int m, int below [])
{
------ Int I, k = 0; float aver = 0;
For (I = 0; I <m; I ++)
Aver + = (score [I]);
Aver/= m;
For (I = 0; I <m; I ++)
If (score [I] <aver)
{Below [k] = score [I];
... The remaining full text>
C language makes up three natural numbers, such as the relationship between a B c. I have compiled the relationship, but I am prompted an error. I don't know where it is wrong.
The syntax of conditional expressions is basically incorrect.
If (no1 <no2 <no3) case1 ++;
If (no1 <no2) & (no2 <no3 ))...
If (no1> no2> no3) case2 ++;
If (no1> no2) & (no2> no3 ))....
If (no1 = no2 = no3) case3 ++;
If (no1 = no2) & (no2 = no3 ))....
There are other conditional expressions...