Home > Back-end >  Five students four grades, calculate the average, and average
Five students four grades, calculate the average, and average

Time:06-04

With an average sort, and print out the form, I am really not, head all big, save the children
And we haven't learned a pointer, can only use simple function
# include & lt; Stdio. H>

Int main () {
int i,j;
Float a [5], [4], the sum [4]={0};
Printf (" \ t 2 \ \ t course 1 \ t t 3 \ t course 4 \ n ");
for(i=0; i<5; I++) {
Printf (" % d ", I + 1);
for(j=0; J<4. J++)
The scanf (" % f ", & amp; A [I] [j]);
}
for(j=0; J<4. J++)
for(i=0; i<5; I++)
The sum [I] +=a, [I] [j].

Printf (" the result for t \ \ t \ n ");
Printf (" \ t 1 \ t course 2 \ t 3 \ t course scored an average 4 \ t \ n ");
for(i=0; i<5; I++) {
Printf (" \ n students % d: \ t ", I + 1);
for(j=0; J<4. J++)
Printf (" % 1 \ t f ", a [I] [j]);
Printf (" % 1 f ", sum [I]/4);
printf("\n");
}
return 0;
}

CodePudding user response:

The same question, don't have to repeatedly post
Write code to sort the sum to do, and then in the sorting process of sum data exchange content came out of an array of synchronous exchange a
Just this one step

CodePudding user response:

# include
# define N 5
The main ()
{
Int a [N] [5], I, j, N, x, y, z;
Printf (" please enter student id and attendance points, interior points \ n ");
for(i=0; ifor(j=0; J<3; J++)
{the scanf (" % d ", & amp; A [I] [j]); }
for(i=0; i{
For (a [I] [3]=0, j=1; J<3; J++)
{a [I] [3] +=a, [I] [j]. }
}
Printf (" please enter a query student id: ");
The scanf (" % d ", & amp; n);
i=0;
While (i{i++; }
If (i{
Printf (" the student's attendance points, interior points, total score is: ");
for(j=1; J<4. J++)
Printf (" % 4 d ", a [I] [j]);
printf("\n");
}
The else printf (" the student you are looking for does not exist \ n ");
for(i=0; i{
for(j=i+1; J{
For (z=0; Z<4. Z++)
If (a [I] [3] {
X=a, [I] [z].
A [I] [z]=a, [j] [z].
A [j] [z]=x;
}
}
}
for(i=0; i{a [I] [4]=I + 1; }
Printf (" output after sorting result table \ n ");
Printf (" student id attendance interior points total score ranking \ n ");
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
for(i=0; i{
for(j=0; J<5; J++)
Printf (" % d "6, a [I] [j]);
printf("\n");
}
}//you can consult me to write this topic

CodePudding user response:

Fun
reference 1 floor response:
the same question, don't have to repeatedly post
Write code to sort the sum to do, and then in the sorting process of sum data exchange content came out of an array of synchronous exchange a
Just this one step

Brother mind private chat here, I changed after the appearance of some new strange questions

CodePudding user response:

# include & lt; Stdio. H>

Int main ()
{
Int I, j, k, t;
Float a [5], [4], the sum [5]={0};
Printf (" \ t 2 \ \ t course 1 \ t t 3 \ t course 4 \ n ");
for(i=0; i<5; I++) {
Printf (" % d ", I + 1);
for(j=0; J<4. J++)
The scanf (" % f ", & amp; A [I] [j]);
}

for(i=0; i<5; I++)
for(j=0; J<4. J++)
The sum [I] +=a, [I] [j].

for(i=0; i<5; I++) {
for(j=0; J<5 - I - 1; J++) {
If (sum [j] T=sum [j];
[j]=sum sum [j + 1);
The sum [m + 1]=t;
}
for(k=0; k<4. K++) {
T=a, [j] [k].
A [j] [k]=[m + 1] a [k].
+ 1 a [j] [k]=t;
}
}
}

Printf (" the result for t \ \ t \ n ");
Printf (" \ t 1 \ t course 2 \ t 3 \ t course scored an average 4 \ t \ n ");
for(i=0; i<5; I++) {
Printf (" \ n % d students: ", I + 1);
for(j=0; J<4. J++)
Printf (" % 1 \ t f ", a [I] [j]);
Printf (" % 1 f ", sum [I]/4);
printf("\n");
}
return 0;
}

CodePudding user response:

An array of the sum is missing a
The bubbling second cycle control

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related