杭电1084怎么解决,代码如下,wa,但是测试数据都对
#include<stdio.h>#include<string.h>intmain(){intn;while(scanf("%d",&n),n!=-1){intnum[...
#include <stdio.h>
#include <string.h>int main()
{
int n;
while(scanf("%d",&n),n!=-1)
{
int num[101],i,seq[6]={0,0,0,0,0,0};
char time[101][10];
int sco[101];
memset(sco,0,sizeof(sco));
for(i=0;i<n;i++)
{
scanf("%d",&num[i]);
scanf("%s",time[i]);
}
for(i=0;i<n;i++)
{
if(num[i]==5)sco[i]=100;
if(num[i]==4){sco[i]=90;seq[4]++;}
if(num[i]==3){sco[i]=80;seq[3]++;}
if(num[i]==2){sco[i]=70;seq[2]++;}
if(num[i]==1){sco[i]=60;seq[1]++;}
if(num[i]==0){sco[i]=50;seq[0]++;}
}
char s1[11]={"99:99:99"};
char s2[11]={"99:99:99"};
char s3[11]={"99:99:99"};
char s4[11]={"99:99:99"};
int t1,t2,t3,t4;
for(i=0;i<n;i++)
{
if(num[i]==4)
{
if(strcmp(s1,time[i])>0)
{
strcpy(s1,time[i]);
t1=i;
}
}
if(num[i]==3)
{
if(strcmp(s2,time[i])>0)
{
strcpy(s2,time[i]);
t2=i;
}
}
if(num[i]==2)
{
if(strcmp(s3,time[i])>0)
{
strcpy(s3,time[i]);
t3=i;
}
}
if(num[i]==1)
{
if(strcmp(s4,time[i])>0)
{
strcpy(s4,time[i]);
t4=i;
}
}
}
for(i=0;i<n;i++)
{
if(i==t1&&seq[4]>1)
sco[i]+=5;
if(i==t2&&seq[3]>1)
sco[i]+=5;
if(i==t3&&seq[2]>1)
sco[i]+=5;
if(i==t4&&seq[1]>1)
sco[i]+=5;
}
for(i=0;i<n;i++)
printf("%d\n",sco[i]);
printf("\n");
}
return 0;
} 展开
#include <string.h>int main()
{
int n;
while(scanf("%d",&n),n!=-1)
{
int num[101],i,seq[6]={0,0,0,0,0,0};
char time[101][10];
int sco[101];
memset(sco,0,sizeof(sco));
for(i=0;i<n;i++)
{
scanf("%d",&num[i]);
scanf("%s",time[i]);
}
for(i=0;i<n;i++)
{
if(num[i]==5)sco[i]=100;
if(num[i]==4){sco[i]=90;seq[4]++;}
if(num[i]==3){sco[i]=80;seq[3]++;}
if(num[i]==2){sco[i]=70;seq[2]++;}
if(num[i]==1){sco[i]=60;seq[1]++;}
if(num[i]==0){sco[i]=50;seq[0]++;}
}
char s1[11]={"99:99:99"};
char s2[11]={"99:99:99"};
char s3[11]={"99:99:99"};
char s4[11]={"99:99:99"};
int t1,t2,t3,t4;
for(i=0;i<n;i++)
{
if(num[i]==4)
{
if(strcmp(s1,time[i])>0)
{
strcpy(s1,time[i]);
t1=i;
}
}
if(num[i]==3)
{
if(strcmp(s2,time[i])>0)
{
strcpy(s2,time[i]);
t2=i;
}
}
if(num[i]==2)
{
if(strcmp(s3,time[i])>0)
{
strcpy(s3,time[i]);
t3=i;
}
}
if(num[i]==1)
{
if(strcmp(s4,time[i])>0)
{
strcpy(s4,time[i]);
t4=i;
}
}
}
for(i=0;i<n;i++)
{
if(i==t1&&seq[4]>1)
sco[i]+=5;
if(i==t2&&seq[3]>1)
sco[i]+=5;
if(i==t3&&seq[2]>1)
sco[i]+=5;
if(i==t4&&seq[1]>1)
sco[i]+=5;
}
for(i=0;i<n;i++)
printf("%d\n",sco[i]);
printf("\n");
}
return 0;
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询