#include <iostream>
#include <string>
#include <sstream>
using namespace std;
wstring encrypt(const wstring &s) {
wstringstream result;
setlocale(LC_ALL, "ru");
for (wstring::size_type i = 0; i < s.size(); i++) {
switch (s[i]) {
case L'А':
result << L"•−" << L' ';
break;
case L'Б':
result << L'-' << L' ';
break;
default:
return L"Ошибка! Символ не найден в базе";
}
}
return result.str();
}
// string decrypt() {}
int main() {
setlocale(LC_ALL, "ru");
wstring s;
wcin >> s;
wcout << encrypt(s);
}
/usr/bin/c++ -g -MD -MT CMakeFiles/AzbukaMorze.dir/main.cpp.o -MF CMakeFiles/AzbukaMorze.dir/main.cpp.o.d -o CMakeFiles/AzbukaMorze.dir/main.cpp.o -c /home/nikita/CLionProjects/AzbukaMorze/main.cpp
/home/nikita/CLionProjects/AzbukaMorze/main.cpp:20:24: warning: character constant too long for its type
20 | return L'Неизвестный символ в строке! Работа программы прервана';
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/nikita/CLionProjects/AzbukaMorze/main.cpp: In function ‘std::wstring encrypt(const std::wstring&)’:
/home/nikita/CLionProjects/AzbukaMorze/main.cpp:20:24: error: could not convert ‘1072’ from ‘wchar_t’ to ‘std::wstring’ {aka ‘std::__cxx11::basic_string<wchar_t>’}
20 | return L'Неизвестный символ в строке! Работа программы прервана';
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| wchar_t
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
wstring encrypt(const wstring &s) {
wstringstream result;
for (wstring::size_type i = 0; i < s.size(); i++) {
switch (s[i]) {
case L'А':
result << "•−" << " ";
break;
case L'Б':
result << "-" << " ";
break;
default:
cout << "Неизвестный символ в строке! Работа программы прервана" << endl;
return 0;
}
}
return result.str();
}
// string decrypt() {}
int main() {
wstring s;
wcin >> s;
wcout << encrypt(s);
}
/home/nikita/CLionProjects/AzbukaMorze/main.cpp:11:18: warning: multi-character character constant [-Wmultichar]
11 | case 'А':
| ^~~
/home/nikita/CLionProjects/AzbukaMorze/main.cpp: In function ‘std::string encrypt(const std::wstring&)’:
/home/nikita/CLionProjects/AzbukaMorze/main.cpp:22:22: error: could not convert ‘std::__cxx11::basic_stringstream<_CharT, _Traits, _Alloc>::str() const [with _CharT = wchar_t; _Traits = std::char_traits<wchar_t>; _Alloc = std::allocator<wchar_t>; __string_type = std::__cxx11::basic_string<wchar_t>]()’ from ‘basic_string<wchar_t>’ to ‘basic_string<char>’
22 | return result.str();
| ~~~~~~~~~~^~
| |
| basic_string<wchar_t>
/home/nikita/CLionProjects/AzbukaMorze/main.cpp: In function ‘int main()’:
/home/nikita/CLionProjects/AzbukaMorze/main.cpp:30:10: error: expected ‘;’ before ‘encrypt’
30 | wcout encrypt(s);
| ^~~~~~~~
| ;
ninja: build stopped: subcommand failed.