题目链接https://www.patest.cn/contests/pat-b-practise/1055
注意事项
1.按照名字升序比较时,不应该用char 的数组,而是应该用string.
2.vector 建立数组
3.最后一行的人数final=n/k+n%k;
4.循环中int i=1;?
题目代码
#include
#include
#include
#include
using namespace std;
struct student
{
string name;
int heigh;
};
bool compare(struct student a,struct student b)
{
if(a.heigh!=b.heigh)
return a.heigh>b.heigh;
else
{
return a.name>N>>k;
vector v(N);
for(int i=0;i>v[i].name>>v[i].heigh;
}
sort(v.begin(),v.end(),compare);
int col=N/k;
int final=N/k+N%k;
string result="";
for(int i=0;i