杭电acm 1236 提交总是“Wrong Answer” 哪里错了?求解释!!!谢了
http://acm.hdu.edu.cn/showproblem.php?pid=1236#include<iostream>#include<string.h>usi...
http://acm.hdu.edu.cn/showproblem.php?pid=1236
#include<iostream>
#include<string.h>
using namespace std;
struct student
{
char num[21];
int m;
int topic[11];
}stu[1001];
int main()
{
int N,M,G;
//freopen("1236.txt","r",stdin);
while(cin>>N && N!=0)
{
cin>>M>>G;
int grade[11];
int i,j=0;
int k,people=0;
int score[1001];
memset(score,0,sizeof(score));
for(i=1; i<=M; i++)
{
cin>>grade[i];
}
for(i=1; i<=N; i++)
{
cin>>stu[i].num;
cin>>stu[i].m;
for(j=1; j<=stu[i].m; j++)
{
cin>>stu[i].topic[j];
k=stu[i].topic[j];
score[i]+=grade[k];
}
if(score[i]>=G)
{
people++;
}
}
for(i=1; i<=N-1; i++)
{
k=i;
for(j=i+1; j<=N; j++)
{
if(score[k]<score[j])
{
k=j;
}
else if(score[k]==score[j])
{
if(strcmp(stu[k].num,stu[j].num)>0)
{
k=j;
}
}
if(k!=i)
{
int z;
z=score[i];
score[i]=score[k];
score[k]=z;
char t[21];
strcpy(t,stu[i].num);
strcpy(stu[i].num,stu[k].num);
strcpy(stu[k].num,t);
}
}
}
cout<<people<<endl;
for(i=1; i<=people; i++)
{
cout<<stu[i].num<<" "<<score[i]<<endl;
}
}
return 0;
} 展开
#include<iostream>
#include<string.h>
using namespace std;
struct student
{
char num[21];
int m;
int topic[11];
}stu[1001];
int main()
{
int N,M,G;
//freopen("1236.txt","r",stdin);
while(cin>>N && N!=0)
{
cin>>M>>G;
int grade[11];
int i,j=0;
int k,people=0;
int score[1001];
memset(score,0,sizeof(score));
for(i=1; i<=M; i++)
{
cin>>grade[i];
}
for(i=1; i<=N; i++)
{
cin>>stu[i].num;
cin>>stu[i].m;
for(j=1; j<=stu[i].m; j++)
{
cin>>stu[i].topic[j];
k=stu[i].topic[j];
score[i]+=grade[k];
}
if(score[i]>=G)
{
people++;
}
}
for(i=1; i<=N-1; i++)
{
k=i;
for(j=i+1; j<=N; j++)
{
if(score[k]<score[j])
{
k=j;
}
else if(score[k]==score[j])
{
if(strcmp(stu[k].num,stu[j].num)>0)
{
k=j;
}
}
if(k!=i)
{
int z;
z=score[i];
score[i]=score[k];
score[k]=z;
char t[21];
strcpy(t,stu[i].num);
strcpy(stu[i].num,stu[k].num);
strcpy(stu[k].num,t);
}
}
}
cout<<people<<endl;
for(i=1; i<=people; i++)
{
cout<<stu[i].num<<" "<<score[i]<<endl;
}
}
return 0;
} 展开
展开全部
#include<iostream>
#include<string.h>
using namespace std;
struct student
{
char num[21];
int m;
int topic[11];
}stu[1001];
int main()
{
int N,M,G;
//freopen("1236.txt","r",stdin);
while(cin>>N && N!=0)
{
cin>>M>>G;
int grade[11];
int i,j=0;
int k,people=0;
int score[1001];
memset(score,0,sizeof(score));
for(i=1; i<=M; i++)
{
cin>>grade[i];
}
for(i=1; i<=N; i++)
{
cin>>stu[i].num;
cin>>stu[i].m;
for(j=1; j<=stu[i].m; j++)
{
cin>>stu[i].topic[j];
k=stu[i].topic[j];
score[i]+=grade[k];
}
if(score[i]>=G)
{
people++;
}
}
for(i=1; i<=N-1; i++)
{
k=i;
for(j=i+1; j<=N; j++)
{
if(score[k]<score[j])
{
k=j;
}
else if(score[k]==score[j])
{
if(strcmp(stu[k].num,stu[j].num)>0)
{
k=j;
}
}
}
if(k!=i) // 选择排序的交换放在j的循环后面
{
int z;
z=score[i];
score[i]=score[k];
score[k]=z;
char t[21];
strcpy(t,stu[i].num);
strcpy(stu[i].num,stu[k].num);
strcpy(stu[k].num,t);
}
}
cout<<people<<endl;
for(i=1; i<=people; i++)
{
cout<<stu[i].num<<" "<<score[i]<<endl;
}
}
return 0;
}
#include<string.h>
using namespace std;
struct student
{
char num[21];
int m;
int topic[11];
}stu[1001];
int main()
{
int N,M,G;
//freopen("1236.txt","r",stdin);
while(cin>>N && N!=0)
{
cin>>M>>G;
int grade[11];
int i,j=0;
int k,people=0;
int score[1001];
memset(score,0,sizeof(score));
for(i=1; i<=M; i++)
{
cin>>grade[i];
}
for(i=1; i<=N; i++)
{
cin>>stu[i].num;
cin>>stu[i].m;
for(j=1; j<=stu[i].m; j++)
{
cin>>stu[i].topic[j];
k=stu[i].topic[j];
score[i]+=grade[k];
}
if(score[i]>=G)
{
people++;
}
}
for(i=1; i<=N-1; i++)
{
k=i;
for(j=i+1; j<=N; j++)
{
if(score[k]<score[j])
{
k=j;
}
else if(score[k]==score[j])
{
if(strcmp(stu[k].num,stu[j].num)>0)
{
k=j;
}
}
}
if(k!=i) // 选择排序的交换放在j的循环后面
{
int z;
z=score[i];
score[i]=score[k];
score[k]=z;
char t[21];
strcpy(t,stu[i].num);
strcpy(stu[i].num,stu[k].num);
strcpy(stu[k].num,t);
}
}
cout<<people<<endl;
for(i=1; i<=people; i++)
{
cout<<stu[i].num<<" "<<score[i]<<endl;
}
}
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询