C # Print score table code

Source: Internet
Author: User

Title: A class of 6 people, from the keyboard input each study number language, mathematics, foreign language results (no need to enter the number).

Output: Student score table (including each person's total score), the average score for each section.
Add 1: Try to show the failing words in red.
Add 2: Try to sort by the total score, show the ranking out.

static void Main (string[] args)
{
int[,] A = new int[6, 5];
for (int i = 0; i < 6; i++)
{
A[i, 0] = i + 1;
Console.Write ("Please enter" + (i + 1) + "Student's language Score:");
A[i, 1] = Convert.ToInt32 (Console.ReadLine ());
Console.Write ("Please enter" + (i + 1) + "Student's math Score:");
A[i, 2] = Convert.ToInt32 (Console.ReadLine ());
Console.Write ("Please enter" + (i + 1) + "Student's English Score:");
A[i, 3] = Convert.ToInt32 (Console.ReadLine ());
A[i, 4] = a[i, 1] + a[i, 2] + a[i, 3];
Console.clear ();
}
for (int i = 1; i < 6; i++)
{
for (int j = 1; j < 7-i; J + +)
{
if (A[j, 4] > A[j-1, 4])
{
int min = 0;
Min = a[j, 4];
A[j, 4] = a[j-1, 4];
A[j-1, 4] = min;

int Xuehao = 0;
Xuehao = a[j, 0];
A[j, 0] = a[j-1, 0];
A[j-1, 0] = Xuehao;

int yuwen = 0;
Yuwen = A[j, 1];
A[j, 1] = a[j-1, 1];
A[j-1, 1] = Yuwen;

int shuxue = 0;
Shuxue = A[j, 2];
A[j, 2] = a[j-1, 2];
A[j-1, 2] = Shuxue;

int Yingyu = 0;
Yingyu = A[j, 3];
A[j, 3] = a[j-1, 3];
A[j-1, 3] = Yingyu;
}
}
}

Console.WriteLine ("Study number \ t language \ t math \ t English t total score \ T");
for (int n = 0; n < 6; n++)
{
for (int m = 0; m < 5; m++)
{
if (A[n, M] < 60&&m>0&&m<4)
{
Console.foregroundcolor = consolecolor.red;
}
Console.Write (A[n, m] + "\ t");
Console.foregroundcolor = Consolecolor.gray;
}
Console.Write ((n+1) + "\ n");
}
Double yw = 0, sx = 0, yy = 0;
for (int k = 0; k < 6; k++)
{
yw = yw + a[k, 1];
SX = SX + a[k, 2];
yy = yy + a[k, 3];
}
yw = YW/6;
SX = SX/6;
yy = YY/6;
yw = convert.todouble (yw. ToString ("#.00"));
SX = convert.todouble (SX. ToString ("#.00"));
yy = Convert.todouble (yy. ToString ("#.00"));
Console.WriteLine ("Average division \ T" + yw + "\ t" + SX + "\ T" + yy + "\ t");

}

Among the issues to note:

1. The first analysis of the problem, the whole process can be divided into the following sections:

A, input score B, bubble sort c, Output table D, change the font color E, find the average score

2. Be careful to arrange all the preceding order in the bubble sort

3. Change the color of the font need to separate output, and output one after the color change back

C # Print score table code

Related Article

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.