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 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64