[Cpp]/** Copyright and version statement of the program section * Copyright (c) 2013, student * All rightsreserved from computer College of Yantai University. * file name: score. cpp * Author: Ji Zilong * Completion Date: July 15, March 8, 2013 * version: v1.0 www.2cto.com * input Description: initialized in the Program * Problem description: The Student Score information is stored in the struct array, sort the struct and output * output: Student transcript in descending order of C ++ and ascending order of student ID */# include <iostream> using namespace std; struct Score {char num [14]; int cpp; int math; int english ;};// the void sort1 function to be customized (Score p [], int n ); void sort2 (Score p [], int n); void output (Score p [], int); int main () {Score [] = {"201152501104 ", 201152501114, 69, 68}, {"201152501138", 94, 89, 63}, {"201152501204", 67, 62, 84}, {"100", 65, 91 },{ "201152501202", 59, 80, 55 },{ "201152501115", 92, 84, 60 },{ "201152501201", 80, 92, 71 }, {"201152501145", 88, 56, 67}, {"201152501203", 62, 62, 95}, {"201152501140", 80, 60, 86 }, {& quot; 201152501205 & quot;, 73, 90, 94 }}; int stuNum = sizeof (score)/sizeof (score [0]); // sort all students by C ++ in descending order and then output sort1 (score, stuNum); cout <"sort by C ++ in descending order:" <endl; output (score, stuNum); // sort all students by student ID in ascending order and then output sort2 (score, stuNum); cout <"after sorting by student ID in ascending order: "<endl; output (score, stuNum); return 0;} void sort1 (Score p [], int n) {int I, j; Score t [50]; for (j = 0; j <n; j ++) for (I = 0; I <n-j; I ++) if (p [I]. cpp> p [I + 1]. cpp) {strcpy (t [I]. num, p [I]. num); strcpy (p [I]. num, p [I + 1]. num); strcpy (p [I + 1]. num, t [I]. num); t [I]. cpp = p [I]. cpp; p [I]. cpp = p [I + 1]. cpp; p [I + 1]. cpp = t [I]. cpp; t [I]. math = p [I]. math; p [I]. math = p [I + 1]. math; p [I + 1]. math = t [I]. math; t [I]. english = p [I]. english; p [I]. english = p [I + 1]. english; p [I + 1]. english = t [I]. english ;}} void sort2 (Score p [], int n) {int I, j; Score t [50]; for (j = 0; j <n; j ++) for (I = 0; I <n-j; I ++) if (strcmp (p [I]. num, p [I + 1]. num)> 0) {strcpy (t [I]. num, p [I + 1]. num); strcpy (p [I + 1]. num, p [I]. num); strcpy (p [I]. num, t [I]. num); t [I]. cpp = p [I + 1]. cpp; p [I + 1]. cpp = p [I]. cpp; p [I]. cpp = t [I]. cpp; t [I]. math = p [I + 1]. math; p [I + 1]. math = p [I]. math; p [I]. math = t [I]. math; t [I]. english = p [I + 1]. english; p [I + 1]. english = p [I]. english; p [I]. english = t [I]. english ;}} void output (Score p [], int n) {int I; for (I = 0; I <n; I ++) cout <p [I]. num <"" <p [I]. cpp <"" <p [I]. english <"<p [I]. math <endl;} running result: