标签:c++ 生活
/*
*copyright(c) 2014,烟台大学计算机学院
*All rights reserved。
*文件名称:14周(二维数组姓名成绩排序)
*作者:王忠
*完成日期:2014.12.01
*版本号:v1.0
*
*问题描述:初始化同学的成绩,姓氏,按大小排序
*输入描述:无
*程序输出:按照姓名或者成绩大小排序并输出
#include <iostream> #include <string> using namespace std; const int num=8; int main() { int i,j,t; string temp; string name[num]={"zhao","qian","sun","li","zhou","wu","zheng","wang"}; double score[num]={79,84,65,89,60,92,78,56}; for (i=0;i<7;i++) for (j=0;j<7-i;j++) if (name[j]>name[j+1]) { temp=name[j]; name[j]=name[j+1]; name[j+1]=temp; t=score[j]; score[j]=score[j+1]; score[j+1]=t; } for (i=0;i<8;i++) { cout<<name[i]<<" "; } cout<<endl; for (i=0;i<8;i++) cout<<score[i]<<" "; return 0; }
标签:c++ 生活
原文地址:http://blog.csdn.net/wangzhongwangmin/article/details/41645445