Write the topic in two ways: Enter the name, language score, Math score, English score to set, to find the Chinese total, math average, English highest score and English highest score is who.
Law one: The practice of a set
Console.Write ("Enter total number of people:");
int s = Int. Parse (Console.ReadLine ());
ArrayList ss = new ArrayList ();
for (int i = 0; i < s; i++)
{
Console.Write ("No." + (i + 1) + "name:");
Ss. ADD (Console.ReadLine ());
Console.Write ("No." + (i + 1) + "English score:");
Ss. ADD (Console.ReadLine ());
Console.Write ("No." + (i + 1) + "Math score:");
Ss. ADD (Console.ReadLine ());
Console.Write ("No." + (i + 1) + "language score:");
Ss. ADD (Console.ReadLine ());
}
for (int i = 1; I <= 4 * s; i + = 4)
{
for (int j = i; J <= 4 * s-4; j + = 4)
{
if (double. Parse (Ss[i]. ToString ()) < double. Parse (Ss[j + 4]. ToString ()))
{
Double ying = double. Parse (Ss[i]. ToString ());
Ss[i] = ss[j + 4];
Ss[j + 4] = ying;
String xing = ss[i-1]. ToString ();
Ss[i-1] = ss[j + 3];
Ss[j + 3] = xing;
Double Shu = double. Parse (Ss[i + 1]. ToString ());
Ss[i + 1] = ss[j + 5];
Ss[j + 5] = Shu;
Double yu = double. Parse (Ss[i + 2]. ToString ());
Ss[i + 2] = ss[j + 6];
Ss[j + 6] = Yu;
}
}
}
for (int i = 0; i < 4 * s; i++)
{
Console.WriteLine (Ss[i]);
}
Double sum1 = 0;
Double sum2 = 0;
for (int i = 0; i < 4 * s; i+=4)
{
Sum1 + = Double. Parse (Ss[i + 2]. ToString ());
Sum2 + = Double. Parse (Ss[i + 3]. ToString ());
}
Console.WriteLine ("Math score:" + sum1);
Console.WriteLine ("Chinese average score:" + (SUM2/S));
Console.WriteLine ("The person with the highest English score is:" + ss[0] + ", score is:" + ss[1]);
Console.ReadLine ();
Law II: procedure of four sets
Console.Write ("Enter total number of people:");
int s = Int. Parse (Console.ReadLine ());
ArrayList ss = new ArrayList ();
ArrayList rr = new ArrayList ();
ArrayList tt = new ArrayList ();
ArrayList yy = new ArrayList ();
for (int i = 0; i < s; i++)
{
Console.Write ("No." + (i + 1) + "name:");
Ss. ADD (Console.ReadLine ());
Console.Write ("No." + (i + 1) + "English score:");
Rr. ADD (Console.ReadLine ());
Console.Write ("No." + (i + 1) + "Math score:");
Tt. ADD (Console.ReadLine ());
Console.Write ("No." + (i + 1) + "language score:");
Yy. ADD (Console.ReadLine ());
}
for (int i = 0; i < s; i++)
{
for (int j = i; J < S-1; J + +)
{
if (double. Parse (Rr[i]. ToString ()) < double. Parse (Rr[j + 1]. ToString ()))
{
Double ying = double. Parse (Rr[i]. ToString ());
Rr[i] = rr[j + 1];
Rr[j + 1] = ying;
String xing = Ss[i]. ToString ();
Ss[i] = ss[j + 1];
Ss[j + 1] = xing;
Double Shu = double. Parse (Tt[i]. ToString ());
Tt[i] = tt[j + 1];
Tt[j + 1] = Shu;
Double yu = double. Parse (Yy[i]. ToString ());
Yy[i] = yy[j + 1];
Yy[j + 1] = Yu;
}
}
}
for (int i = 0; i < s; i++)
{
Console.WriteLine (Ss[i] + "\ t");
Console.WriteLine (Rr[i] + "\ t");
Console.WriteLine (Tt[i] + "\ t");
Console.WriteLine (Yy[i] + "\ t");
}
Double sum1 = 0;
Double sum2 = 0;
for (int i = 0; i < s; i++)
{
Sum1 + = Double. Parse (Tt[i]. ToString ());
Sum2 + = Double. Parse (Yy[i]. ToString ());
}
Console.WriteLine ("Math score:" + sum1);
Console.WriteLine ("Chinese average score:" + (SUM2/S));
Console.WriteLine ("The person with the highest English score is:" + ss[0] + ", score is:" + rr[0]);
Console.ReadLine ();
C#arraylist Collection--small example