dyxm21 2016-06-01 10:26 采纳率: 100%
浏览 1479
已采纳

求c++代码转成java代码⋯⋯⋯⋯

#include
#include
#include
using namespace std;
struct student
{
char name[11];
int solve;
int cost;
}stu[10000];
bool cmp(student a,student b)
{
if(a.solve!=b.solve)
if(a.solve>b.solve)
return true;
else
return false;
else if(a.cost==b.cost)
{
return(strcmp(a.name,b.name)<0);

    }
        else

            return(a.cost<b.cost);

}
int main()
{
int n,m,i,s,k;
char ch;
while(cin>>n>>m)
{
int t=0;
while(cin>>stu[t].name)
{
if(strcmp(stu[t].name,"eof")==0)
break;
for(i=0;i {
cin>>s;
if(s>0)
{
stu[t].solve++;
k=0;
if(getchar()=='(')
{
cin>>k;
cin>>ch;
}
stu[t].cost=stu[t].cost+s+k*m;
}
}
t++;
}
sort(stu,stu+t,cmp);
for(i=0;i<t;i++)
cout<<left<<setw(10)<<stu[i].name<<' '<<right<<setw(2)<<stu[i].solve<<' '<<setw(4)<<stu[i].cost<<endl;
}
return 0;
}

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-06-01 10:44
    关注

    最好给出题目和输入输出数据。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料