Student Score statistics

Source: Internet
Author: User

/*
* Copyright and version Declaration of the program:
* Copyright (c) 2012, computer College, Yantai University
* All rights reserved.
* File name: student achievement statistics. cpp
* Author: Mao Tong
* Completion date: January 1, December 11, 2012
* Version No.: v1.0
* Description of tasks and solutions: Requirements

(1) define a two-dimensional array to store each student's course score

(2) calculate the average score of students in each course (each column), save and Output

(3) calculate the average score (per line) of each course for each student, save and Output

The score is as follows:

Course 1 course 2 course 3

Student 1 89 78 56

Student 2 88 99 100

Student 3 72 80 61

Student 4 60 70 75
* Input Description: None
* Problem description:
* Program output: ""
* Problem Analysis: omitted
* Algorithm Design: omitted
*/

 

[Cpp]
# Include <iostream>
 
# Include <iomanip>
 
Using namespace std;
 
Int main ()
 
{
// Define a two-dimensional array to store each student's course score
Double a [5] [4] =
{
{89, 78, 56 },
{88, 99,100 },
{72, 80, 61 },
{60, 70, 75 },
};
Int val, flag; // val row flag Column

// Calculate the sum of each column based on the average value of each column and divide it by 4
Double sum_1 [3];
For (int I = 0; I <3; I ++)
{
Sum_1 [I] = 0;
}

For (flag = 0; flag <3; flag ++)
For (val = 0; val <4; val ++)
Sum_1 [flag] = sum_1 [flag] + a [val] [flag];

For (flag = 0; flag <3; flag ++)
A [4] [flag] = sum_1 [flag]/4;


// Average score (per row) of each course for each student, save and output:
Double sum_2 [4];
For (I = 0; I <4; I ++)
{
Sum_2 [I] = 0;
}

For (val = 0; val <4; val ++)
For (flag = 0; flag <3; flag ++)
Sum_2 [val] = sum_2 [val] + a [val] [flag];
For (val = 0; val <4; val ++)
A [val] [3] = sum_2 [val]/3;



// Output the orders table
Cout <"tables Table" <"";
For (I = 1; I <= 3; ++ I)
Cout <"Course" <I <"\ t ";
Cout <"average score ";
Cout <endl;

I = 1;
Cout <"Student 1" <"\ t" <"";

For (val = 0; val <4; val ++)
{
For (flag = 0; flag <4; flag ++)
{
Cout <setprecision (4) <a [val] [flag] <"\ t ";
}
I = I + 1;
If (I = 5)
Break;

Cout <endl <"student" <I <"\ t" <"";


// Continue
}
Cout <endl;


Cout <"average score" <"\ t" <"";
For (flag = 0; flag <4; flag ++)
{Www.2cto.com
Cout <setprecision (4) <a [4] [flag] <"\ t ";
}
Cout <endl;

Return 0;
}

/*

Experience:
Knowledge Point summary:
*/

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.