???? OJ platform: Array score statistics

Source: Internet
Author: User

The Avengers League array score statistics

Description

Defines a two-dimensional array of 5 rows and 3 columns, each representing a student's high number, English, and C + + scores. Define a one-dimensional array with 5 elements to store the average score for each student. Please enter the student's course scores, output a transcript with an average score, and an average of all student averages.

Input

15 integers representing 5 students in 3 subjects

Output

Show each student's grade and average score in 5 lines
Show average values for all students (keep two decimal places)

Sample Input
97 78 8778 63 6873 81 8591 87 8876 81 89
Sample Output
97 78 87 87.3378 63 68 69.6773 81 85 79.6791 87 88 88.6776 81 89 82.0081.47
HINT

Can be completed on the basis of the following program framework, additional variables required in the calculation are added by themselves

#include <iostream>

#include <iomanip>

using namespace Std;

int main ()

{

int score[5][3]; An array of saved scores

Double average[5]; An array that holds average scores

int i,j;

Enter your score

for (i=0; i<5; i++)

for (j=0; j<3; j + +)

cin>>score[i][j];

Calculates the average score for each student, saved to the array average




Output transcripts with an average score




Averages the average score and outputs


return 0;

}

Solution:

#include <iostream> #include <iomanip>using namespace Std;int main () {double d;double score[5][3];d ouble Average[5];int i,j;for (i=0; i<5; i++) for (j=0; j<3; j + +) cin>>score[i][j];average[0]= (score[0][0]+score[0 ][1]+SCORE[0][2])/3;average[1]= (score[1][0]+score[1][1]+score[1][2])/3;average[2]= (score[2][0]+score[2][1]+ SCORE[2][2])/3;average[3]= (score[3][0]+score[3][1]+score[3][2])/3;average[4]= (Score[4][0]+score[4][1]+score[4] [2]) /3;d= (Average[0]+average[1]+average[2]+average[3]+average[4])/5;for (i=0;i<=4;i++) {for    (j=0;j<=2;j++)    {        cout<<setiosflags (ios::fixed) <<setprecision (0) <<score[i][j];        cout<< "";    }    Cout<<setiosflags (ios::fixed) <<setprecision (2) <<average[i]<<endl;} Cout<<d;return 0;}


???? OJ platform: Array score statistics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.