Home > Back-end >  The C language
The C language

Time:10-31

Assignment:
Programming calculation of 10 students scored an average of certain courses, and output the highest score

CodePudding user response:

Int I, num=10;
98,90,90,89,87,67,19,100,99,89 int scroe [10]={};
Int allscore=0;
Imt maxscore=0;
Float aver.
for(i=0; i{
Allscore +=score [I];
If (score [I] & gt; Maxscroe)
Maxscroe=score [I];
}
Aver=(float) allscore/(float) num;

The printf (aver);
The printf (maxscore);

No debug, general meaning

CodePudding user response:

# define _CRT_SECURE_NO_WARNINGS
#include
#include
#include
#include
Void stu_aver (double (* a) [6]) {//computing students average score
Double sum;
int i, j;
for (i=0; i <10; + + I) {
Sum=0.0;
For (j=0; J & lt; 5; + + j) {
The sum +=a, [I] [j].
}
A [I] [5]=sum/5;
}
}
Void score_aver (double (* a) [6]) {//subjects average
Double sum;
int i, j;
for (i=0; i <5; + + I) {
Sum=0.0;
For (j=0; J & lt; 10; + + j) {
The sum +=a, [j] [I].
}
A [10] [I]=sum/10;
}
}
Void top_score (char (* c) [20], char (* s) [20], a double (* a) [6]) {//subject highest
Int the row, col, I, j, flag;
Double top;
Printf (" \ n meet the highest \ n ");
Printf (" subject \ \ t t marks \ n ");
for (i=0; i <5; + + I) {
The row=0;
Col=I;
Top=a [0] [I];
flag=0;
For (j=0; J & lt; 10; + + j) {
If (a) [j] [I] & gt; Top) {
Top=a, [j] [I].
The row=j;
}
}
Printf (" % s \ t % 2 f \ \ t t % s ", c [I], top, s (row));
For (j=0; J & lt; 10; + + j) {
[j] [I] the if (a==top) {
If (flag & gt; 1) {
Printf (" % s \ t, "s [j]);
}
+ + flag;
}
}
Putchar (" \ n ");
}
}
Double viriance (double (* a) [6]) {//variance
Double x1=0;
Double x2=0;
int i;
for (i=0; i <10; + + I) {
The x1 +=a, [I] [6].
X2 +=pow (a [I] [6], 2);
}
Return the x2/10 - pow (x1/10, 2);
}
Void input (char (* c) [20], char (* s) [20], a double (* a) [6]) {//input
int i, j;
for (i=0; i <5; + + I) {
Printf (" please enter the first % d course curriculum name \ n ", I + 1);
The scanf (" % s ", c [I]);
}
for (i=0; i <10; + + I) {
Printf (" please enter the first % d student name \ n ", I + 1);
The scanf (" % s ", s [I]);
For (j=0; J & lt; 5; + + j) {
Printf (" please input the student's result \ n ");
Lf the scanf (" % ", & amp; A [I] [j]);
}
}
system("cls");
}
Void the print (char (* c) [20], char (* s) [20], a double (* a) [6]) {//print
int i, j;
Putchar (' \ t ');
for (i=0; i <5; + + I) {
Printf (" % s \ t, c [I]);
}
Printf (" gpa ");
for (i=0; i <10; + + I) {
Printf (" \ t \ n % s ", s [I]);
For (j=0; J & lt; 6; + + j) {
Printf (" % 2 f \ t ", a [I] [j]);
}
}
Printf (" \ n \ n \ n course score \ t ");
For (j=0; J & lt; 5; + + j) {
Printf (" % 2 f \ t ", a [I] [j]);
}
Putchar (" \ n ");
}
Int main () {
Char c [5] [20].//class name
Char s [10] [20].//the student's name
Double a [11] [6].//student achievement
Input (c, s, a);//enter
Stu_aver (a);//students average score
Score_aver (a);//course average score
Print (c, s, a);//print
Top_score (c, s, a);//course high score
Printf (" variance is: % f \ n ", viriance (a));//variance
system("pause");
return 0;
}
  • Related