1059 C语言竞赛 (20分)
2021-03-18 09:27
8888: Minion
0001: Chocolate
1111: Mystery Award
2222: Are you kidding?
8888: Checked
2222: Are you kidding?
代码讲解:这题按题意模拟就可以了
#include
#include
typedef struct stu
{
int y;
int id;
char award[30];
int check;
}stu;
int prime(int n)
{
if(n return 0;
int i;
for(i=2;i*i {
if(n%i==0)
return 0;
}
return 1;
}
int main()
{
int n;
stu s[10001];
int i;
scanf("%d",&n);
for(i=0;i {
s[i].y=0;
s[i].check=0;
}
int id;
for(i=0;i
scanf("%d",&id);
s[id].y=1;
s[id].id=id;
if(i==0)
strcpy(s[id].award,"Mystery Award");
else
if(prime(i+1))
{
strcpy(s[id].award,"Minion");
}
else
strcpy(s[id].award,"Chocolate");
}
int k;
scanf("%d",&k);
for(i=0;i
scanf("%d",&id);
if(s[id].y==0)
printf("%04d: Are you kidding?\n",id);
else
if(s[id].check==1)
printf("%04d: Checked\n",id);
else
{
printf("%04d: %s\n",id,s[id].award);
s[id].check=1;
}
}
return 0;
}