#11488: 測試執行WA進解題卻AC?


qazwexsdc (YourName)

學校 : 臺北市立成功高級中學
編號 : 55608
來源 : [118.165.142.103]
最後登入時間 :
2021-02-05 03:07:09
b515. 摩斯電碼-商競103 -- 103學年度商業類程式設計競賽模擬題 | From: [111.248.103.154] | 發表日期 : 2016-10-30 23:47

為什麼 哪招?

#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
char A[]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
string code[]={".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};
int main()
{
int in,i,j,k;
string a;
while(cin>>in)
{
getline(cin,a);
for(i=0;i<in;i++)
{
getline(cin,a);
int co=-1;
string wh="";
for(j=0;j<a.length();j++)
{
if(a[j]==' ')
{
wh.append(a,co+1,j-co-1);
co=j;
}
else if(j==a.length()-1)
{
wh.append(a,co+1,j-co);
}
for(k=0;k<26;k++)
{
if(wh==code[k])
{
printf("%c",A[k]);
break;
}
}
wh="";
}
printf("\n");
}
}
return 0;
}

 
ZeroJudge Forum