. based on the user input Ten and save it in an array to get the highest score, the lowest score, and the average score .
int scoure[10];//An array that stores 10 data
int i;
int sum;//Total
int max,min,avg;//max, min, average score
for (i=0;i<10;i++) {
printf ("Please enter%d scores", i+1);//Gets the value entered by the user
scanf ("%d", &scoure[i]);
sun+=scoure[i]//Total
}avg=sum/10;//Average Score
MAX=MIN=SCOURE[0];//assumes that the first number is a maximum or a minimum value
for (i=0;i<10i++) {
if (scoure[i]>max) {// Assuming maximum value Scoure[i] is larger than max Max
Max=scoure[i];
}if (scoure[i]<min) {
Min=scoure[i];
}
}
printf (" Highest score :%d, min . %d, average divided into %d\n", max,min,avg);
Sort from highest to lowest based on 5 numbers entered by the user and saved to an array
int num[5];
int I.J.K;
Saves 5 user-entered numbers into an array
for (i=0;i<4;i++) {
printf ("Please enter%d number \ n", i+1);//Gets the value entered by the user
scanf ("%d", &scoure[i]);
}
sort elements in an array ( bubbling sort )
For (i=0;i<4;i++) {// Outer loop Control comparison of number of wheels : N-1
For (j=0;j<4-i;j++) {// Inner Loop controls the number of times each round needs to be compared : N-1-i
if (Num[j]<num[j+1]]) {
K=NUM[J];
NUM[J]=NUM[J+1];
Num[j+1]=k;
}
}
}
sort them from high to low, traverse the output
for (i=0;i<5;i++) {
printf ("%d\t", Nums[i]);
}
. based on the user input Ten number and save it in an array, the user enters the number to be looked up, and if the number is found to print its position in the array, the element you are looking for is not printed in the array .
int numb[10];
int i,seach,flag=0;
Flag Indicates whether to find the specified element ( If it is found to change its value )
based on the number of digits entered by the user and saved to the array
for (i=0;i<10;i++) {
printf ("Please enter%d values: \ n", i+1);
}
Enter the number you want to find
printf ("Please enter the number you want to find; \ n");
scanf ("%d", &seach);
Finds the number and prints its position on the array
for (i=0;i<10;i++) {
if (Seach==numb[i]) {
printf ("The number you are looking for is%d in the array%d position: \ n", Seach,numb[i])
flag=1;//Clear Buffer
break;//End Loop
}
}
if (flag==0) {
printf (" there is no element in the array you are looking for ");
}
print Yang Hui triangle ( two-dimensional array )
1
1 1
1 2 1
1 3 3 1
1 4 6) 4 1
int numbs[5][5];
The number of the first row, the value of the diagonal
for (i=0;i<5;i++) {
numbs[i][]=1;//The first row has a value of 1
numbs[i][i]=1;//Diagonal value is 1
}
for (i=2;i<5;i++) {//starts from the second row
for (j=1;j<i;j++) {//From second column
the value of the current element = The element on the head + The left element on the head
NUMBS[I][J]=NUMBS[I-1][J]+NUMBS[I-1][J-1];
}
}
loop variable Output
for (i=0;i<5;i++) {// line number
for (j=0;j<=i;j++) {// number of columns
printf ("%d\t", Numbs[i][j]);
}
printf ("\ n");// newline
}
Application of C-language based five-array