PTA(Basic Level) 1076:Wifi密码(C语言实现)
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main()
{
int n,i,j=0;
char res[101]={0},a=0,b=0;
scanf("%d",&n);
getchar();//消耗回车
while(n--)
{
for(i=0;i<4;i++)
{
scanf("%c-%c",&a,&b);
getchar();//消耗空格或回车
if(b == 'T')
{
switch(a)
{
case 'A':res[j++]='1';break;
case 'B':res[j++]='2';break;
case 'C':res[j++]='3';break;
case 'D':res[j++]='4';break;
}
}
}
}
res[j]='\0';
printf("%s",res);
return 0;
}