b762
輸入說明 :
輸入有兩行,第一行有一數字N,代表共有N條指令 ( N <= 40 )
第2~N+1行為指令,保證指令只會有提敘中列舉出的三種
輸出說明 :
照著國際蘿莉保護王朝的規則輸出線報,並在最後一行輸出士兵目前為止的戰績( 擊殺次數 / 死亡次數 / 助攻次數 )
會用strcmp就很簡單了,strcmp(s1,s2)假如兩個字串一樣會回傳0
strcmp其實是一個字元一個字元相減(ascii)。
#include<stdio.h>
#include<string.h>
int main()
{
int n;
while(scanf("%d%*c",&n)!=EOF)
{
int kill = 0, die = 0, assist = 0;
char s[20];
char k[]="Get_Kill";
char a[]="Get_Assist";
char d[]="Die";
int flag=0;
while(n--)
{
scanf("%s",s);
if(strcmp(s,k)==0)
{
flag++;
kill++;
switch(flag)
{
case 1:
printf("You have slain an enemie.\n");
break;
case 2:
printf("You have slain an enemie.\n");
break;
case 3:
printf("KILLING SPREE!\n");
break;
case 4:
printf("RAMPAGE~\n");
break;
case 5:
printf("UNSTOPPABLE!\n");
break;
case 6:
printf("DOMINATING!\n");
break;
case 7:
printf("GUALIKE!\n");
break;
default :
printf("LEGENDARY!\n");
break;
}
}
else if(strcmp(s,a)==0)
{
assist++;
}
else if(strcmp(s,d)==0)
{
if(flag<=2)
printf("You have been slained.\n");
else
printf("SHUTDOWN.\n");
die++;
flag=0;
}
}
printf("%d/%d/%d",kill,die,assist);
}
return 0;
}