[Cpp]
/*
* Copyright and version Declaration of the program
* Copyright (c) 2012, a student from the computer College of Yantai University
* All rightsreserved.
* File name: array. cpp
* Author: Yang shaoning
* Completion date: January 1, December 8, 2012
* Version: v1.0
*
* Input Description: None
* Problem description: Define an array and output the result in the order of scores.
*/
# Include <iostream>
# Include <string>
# Include <iomanip>
Using namespace std;
Int main ()
{
Int I, j, k;
String n;
Float score [6] = {98,76, 88,90, 91,85 };
String name [6] = {"yang", "li", "liu", "tian", "zhang", "xu "};
For (I = 0; I <5; ++ I)
For (j = 0; j <5-i; ++ j)
{
If (score [j]> score [j + 1])
{
K = score [j];
Score [j] = score [j + 1];
Score [j + 1] = k;
N = name [j];
Name [j] = name [j + 1];
Name [j + 1] = n;
}
}
For (j = 0; j <6; ++ j)
Cout <name [j] <setw (5) <score [j] <endl;
Return 0;
}
Result:
Result: Come on !!!