/*Univercity:烟台大学 *@Class</A>计134~4 *@Author:薛富磊 *@Time:2013-12-03 *@Function: 杨辉三角赋值 输出 *@Args: *@Return: */ #include <iostream> using namespace std; int main() { char string_name[22]= {'i','o','l','e','v','m','y','u','f','r','i','e','n','d','g','i','r','l','m','a','k','e'}; int string_score[22]= {25,28,27,67,66,88,89,77,95,96,97,98,99,100,91,92,93,94,78,79,80,87}; cout<<"输出按成绩排序的同学名单:\n"; for(int i=0;i<22;i++) { for(int n,t,j=0;j<22-i;j++) { if(string_score[j]>string_score[j+1]) { t=string_score[j+1]; string_score[j+1]=string_score[j]; string_score[j]=t; n=string_name[j+1]; string_name[j+1]=string_name[j]; string_name[j]=n; } } } for(int i=0;i<22;i++) cout<<string_name[i]<<" "; cout<<"\n输出按同学姓名排序的成绩单:\n"; for(int i=0;i<22;i++) { for(int t,n,j=0;j<22-i;j++) { if(string_name[j]>string_name[j+1]) { n=string_name[j+1]; //必须都写的string_name和string_score string_name[j+1]=string_name[j]; string_name[j]=n; t=string_score[j+1]; string_score[j+1]=string_score[j]; string_score[j]=t; } } } for(int i=0;i<22;i++) cout<<string_score[i]<<" "; return 0; } /*心得体会: 看出没 程序猿 乐在其中 输出的: I love u make my girl friend */