我一直在制作一个将字母,数字和标点转换为莫尔斯电码的程序。C++将ASCII转换为莫尔斯电码
随着字母和数字的工作,我希望它。
但与标点符号我不能让它正常工作。我希望有人可以看看我的代码并帮助我。
#include <iostream>
#include <cstring>
#include <sstream>
using namespace std;
char ch;
string morseWord = "";
for(unsigned int i=0; i < word.length(); i++)
{
if(isalpha(word[i]))
{
ch ;
}
}
return morseWord;
}
char ch;
string morseWord = "";
for(unsigned int i=0; i < word.length(); i++)
{
if(isdigit(word[i]))
{
ch = word[i];
ch = toupper(ch);
morseWord += morseCode[ch - '0'];
morseWord += " ";
string morseWord = "";
for(unsigned int i=0; i < word.length(); i++)
{
if(ispunct(word[i]))
{
ch = word[i];
ch = toupper(ch);
morseWord += morseCode[ch - '.'];
morseWord += " ";
}
}
return morseWord;
}
int main()
{
stringstream ss;
string sentence;
string word = "";
code: " << endl;
while(ss >> ToMorse(word) << endl;
cout << PunctuationToMorse(word) << endl;
}
欢迎来到Stack Overflow。请花些时间阅读[The Tour](http://stackoverflow.com/tour),并参阅[帮助中心](http://stackoverflow.com/help/asking)中的资料,了解您可以在这里问。 –
_“但是标点符号不能让它正常工作。”_你的实际问题是什么?什么是投入,预期产出和实际产出? –
此刻我想输入:点,问号和eksklamation标记。当我输入点时,它可以很好地转换它。 但是,当我输入其他两个它给我:?U ???。 –