Directly on the code, mark: Hey.
#include <stdio.h>/** * Record and count the results of a class of students * practice the use of one-dimensional arrays */intMainvoid){intCount printf"How many students is in your class?\n"); scanf"%d", &count);//Get the number of students in the class /** * I read in the book that it is not allowed to assign a variable to this, but * in my attempt is possible, do not know how. */ intNumbers[count],chinese[count],maths[count],eng[count]; Puts"Please input the StudentID and three scores:\n"); printf"StudentID Chinese Math english\n");inti =0;/** * Accept user's score input */ for(i =0; i < count;i++) {printf ("No.%d>", i+1); scanf"%d %d%d%d", &numbers[i],&chinese[i],&maths[i],&eng[i]); }/** * After the input is completed, the output user's score and their average score */printf"ID CH MA EN ave\n"); printf"--------------------------\ n");intJ for(j =0; J < count;j++) {floatAve = (Chinese[j] + maths[j] + eng[j])/3;//Find out the average scoreprintf"%d\t%d\t%d\t%d\t%f\n", Numbers[j],chinese[j],maths[j],eng[j],ave); }/** * Cycle to find the total scores of each section * * floatAve_chinese =0, ave_math=0, Ave_english =0;intM for(M =0; m < count;m++) {Ave_chinese + = chinese[m]; Ave_math + = Maths[m]; Ave_english + = Eng[m]; }//Output average scoreprintf"The Average of Chinese in this class is%f\n", Ave_chinese/count); printf"The Average of math in this class is%f\n", Ave_math/count); printf"The Average of 中文版 in this class is%f\n", Ave_english/count);return 0;}
Here are the results of my program's operation:
Record a class performance practice one-dimensional array