[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: Qiu xuewei * Completion Date: July 15, March 11, 2013 * version: v1.0 * input Description: initialized in the Program * Problem description: store the Student Score information 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 ;}; void sort1 (Score [], int ); // The void sort2 (Score [], int) function to be customized; void output (Score [], int); int main () {Score score [] = {"201152501104", 201152501114, 68}, {"201152501138", 94, 89, 63}, {"", 67, 62, 84 },{ "201152501204", 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 },{ "201152501205", 73, 90, 94 }}; int stuNum = sizeof (score) /sizeof (score [0]); // sort all students in descending order of C ++ and then output sort1 (score, stuNum ); cout <"sorted 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 <"sort by student ID in ascending order:" <endl; output (score, stuNum); return 0;} void sort1 (Score s [], int n) {int I, j; Score t; for (I = 0; I <N-2; I ++) {for (j = 0; j <n-i-1; j ++) {if (s [j]. cpp <s [j + 1]. cpp) {t = s [j]; s [j] = s [j + 1]; s [j + 1] = t ;}} return ;} void sort2 (Score s [], int n) {int I, j; Score t; for (I = 0; I <N-2; I ++) {for (j = 0; j <n-i-1; j ++) {if (strcmp (s [j]. num, s [j + 1]. num)> 0) {t = s [j]; s [j] = s [j + 1]; s [j + 1] = t ;}} return ;} void output (Score s [], int n) {int I; for (I = 0; I <n; I ++) {cout <s [I]. num <"" <s [I]. cpp <"" <s [I]. math <"<s [I]. english <endl;} return ;}