精華區beta NTUBIME101HW 關於我們 聯絡資訊
#include <iostream> #include <fstream> using namespace std; char morse[28][7] = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....","..",".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-",".-.","...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..","--..--",".-.-.-"}; ofstream SaveFile("MorseC.dat"); void MorseFun(int c) { for(int i=0;i<7;i++) { cout<<morse[c][i]; SaveFile<<morse[c][i]; } } int _tmain(int argc, _TCHAR* argv[]) { ifstream OpenFile("MorseC.txt"); char character; OpenFile>>character; while(!OpenFile.eof() ) { int Num=character; if(Num>=65&&Num<=90) MorseFun(Num-65); if(Num>=97&&Num<=122) MorseFun(Num-97); if(Num==32) cout<<" "; character=OpenFile.get(); } OpenFile.close(); SaveFile.close(); system("PAUSE"); return 0; } 電腦宕了兩次......是不是做壞事了@@? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.241.88