#42010: cpp建表 + 少輸出一行的


dvbdarcyvolleyball@gmail.com (no love)

學校 : 新北市私立南山高級中學
編號 : 266888
來源 : [36.229.120.41]
最後登入時間 :
2024-11-23 16:20:24
b515. 摩斯電碼-商競103 -- 103學年度商業類程式設計競賽模擬題 | From: [123.252.121.18] | 發表日期 : 2024-09-19 20:04

 

 

#include <bits/stdc++.h> //d353 //b969 //b523 //b524 //b526 //a538
#define fast_as_a_fuckboy ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

int main(){ 
  fast_as_a_fuckboy
  int n;
  cin >> n;
  string s;
  map<string,string> m={{".-","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"}};
  cin.ignore();
  for(int i=0;i<=n;i++){   // 就是這行,照理來說 i < n 就可以輸出正確的範例,但居然要加一個=?????
    getline(cin,s);
    stringstream ss(s);
    while(ss>>s){
      cout << m[s];
    }
    cout << "\n";
    s.clear();
  }
}

 
ZeroJudge Forum