#include <bits/stdc++.h>
using namespace std;
string mes(string s) {
for (int i = 0; i <= s.size(); i++) {
if (s[i] == ' ')
cout << " ";
else if (s[i] == 'a')
cout << "·-" << " ";
else if (s[i] == 'b')
cout << "-···" << " ";
else if (s[i] == 'c')
cout << "-·-·" << " ";
else if (s[i] == 'd')
cout << "-··" << " ";
else if (s[i] == 'e')
cout << "·" << " ";
else if (s[i] == 'f')
cout << "··-·" << " ";
else if (s[i] == 'g')
cout << "--·" << " ";
else if (s[i] == 'h')
cout << "····" << " ";
else if (s[i] == 'i')
cout << "··" << " ";
else if (s[i] == 'j')
cout << "·---" << " ";
else if (s[i] == 'k')
cout << "-·-" << " ";
else if (s[i] == 'l')
cout << "·-··" << " ";
else if (s[i] == 'm')
cout << "--" << " ";
else if (s[i] == 'n')
cout << "-·" << " ";
else if (s[i] == 'o')
cout << "---" << " ";
else if (s[i] == 'p')
cout << "·--·" << " ";
else if (s[i] == 'q')
cout << "--·-" << " ";
else if (s[i] == 'r')
cout << "·-·" << " ";
else if (s[i] == 's')
cout << "···" << " ";
else if (s[i] == 't')
cout << "-" << " ";
else if (s[i] == 'u')
cout << "··-" << " ";
else if (s[i] == 'v')
cout << "···-" << " ";
else if (s[i] == 'w')
cout << "·--" << " ";
else if (s[i] == 'x')
cout << "-··-" << " ";
else if (s[i] == 'y')
cout << "-·--" << " ";
else if (s[i] == 'z')
cout << "--··" << " ";
}
}
int main() {
string a;
getline(cin, a);
mes(a);
return 0;
}
字符串转莫尔斯电码
最新推荐文章于 2024-10-04 17:07:53 发布
本文介绍了如何使用C++中的for循环和if-else条件语句,将输入的字符串转换为ASCII艺术形式并在控制台上显示。
摘要由CSDN通过智能技术生成