高额奖励!ACM的一个水问题需要使用结构,通过后必须采用。

# include & ltiostream & gt

# include & ltcstdio & gt

# include & ltcstring & gt

# include & ltcmath & gt

# include & lt算法& gt

# include & ltcctype & gt

使用命名空间std

结构节点

{

char name[30];

int num

int k;//输入序列

} s[1234];

int cmp(节点a,节点b)

{

如果(数量= =数量)

返回a.k & ltb.k

返回a.num & ltb.num

}

int main()

{

int n;

while(scanf("%d ",& ampn)!=EOF)

{

for(int I = 0;我& ltn;i++)

{

scanf("%s %d ",s[i])。姓名& amps[i]。num);

s[i]。k = I;

}

sort(s,s+n,CMP);

for(int I = 0;我& ltn;i++)

printf("%s %d\n ",s[i]。姓名,s[i]。num);

}

返回0;

}