weixin_43825632
weixin_43825632
2018-12-09 16:55

杭电oj2093测试样例对了,但是提交的时候显示wrong answer

#include
#include
#include
#include
#include
using namespace std;
struct student
{
char name[20];
int sumsolve;
int sumscore;
}people[10000],temp;
int main ()
{
int n,m;
cin>>n>>m;
getchar();
int i=0,j;
while(cin>>people[i].name)
{
char str1[10],str2[10],str[10];
people[i].sumsolve=0;
people[i].sumscore=0;
for (j=0;j {
cin>>str;
if (str[0]>='1'&&str[0]<='9')
{
int k,t=0;
people[i].sumsolve++;
for (k=0;k if(str[k]=='(')
break;
if(k {
for (k=0;str[k]!='(';k++)
str1[t++]=str[k];
str1[t]='\0';
t=0;
for (k++;str[k]!=')';k++)
str2[t++]=str[k];
str2[t]='\0';
people[i].sumscore+=atoi(str1)+atoi(str2)*m;
}
else
{
for (k=0;k str1[t++]=str[k];
str1[t]='\0';
people[i].sumscore+=atoi(str1);
}
}
}
getchar();
i++;
}
for (i=0;i for (j=i+1;j {
if(people[i].sumsolve {
temp=people[i];
people[i]=people[j];
people[j]=temp;
}
else if(people[i].sumsolve==people[j].sumsolve)
{
if(people[i].sumscore>people[j].sumscore)
{
temp=people[i];
people[i]=people[j];
people[j]=temp;
}
else if(people[i].sumscore==people[j].sumscore)
{
if(strcmp(people[i].name,people[j].name))
{
temp=people[i];
people[i]=people[j];
people[j]=temp;
}
}
}
}
for (i=0;i<6;i++)
cout<<setiosflags(ios::left)<<setw(10)<<people[i].name<<" "<<setw(2)<<people[i].sumsolve<<" "<<setw(4)<<people[i].sumscore<<endl;
}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

相关推荐