成绩处理(按分数排名)

#include<iostream>
#include<string>
using namespace std;
int main()
{
	cout<<"按成绩排序"<<endl;
	double a[20]={86,76,62,58,77,85,92,80,96,88,77,67,80,68,88,87,64,59,61,76};  
    string name[20]={"yang","rong","wang","zhao","song","zhong","liu"
		,"bao","cai","fan","guang","hao","gai","kai","lai","man","nan","tai","yuan","a"};  
	string mum;
    int i,j,t;  
    for(j=0;j<=19;++j)  
        for(i=0;i<=19;++i)  
        {  
            if(a[i]<a[i+1])  
            {  
                t=a[i];  
                a[i]=a[i+1];  
                a[i+1]=t; 
				mum=name[i];
				name[i]=name[i+1];
				name[i+1]=mum;
            }  
        } 
	
    for(i=0;i<19;++i)  
      cout<<name[i]<<" "<<a[i]<<endl; 
	return 0;  
}  


运行结果:

成绩处理(按分数排名)_第1张图片

你可能感兴趣的:(成绩处理(按分数排名))