Zdravim, ucim sa programovat a mam takyto problem.
to nacitanie a vypis asi nebude vporiadku, ale moc tomu nerozumiem.. ak v morse kode napisem jednotlive znaky oddelene medzerou(nejake slovo), tak mi ich sice vypise ale neodriadkuje. Ako by som mohol docielit odriadkovanie celeho vypisu, teda nastavenie kurzora na novy riadok ? Dakujem za kazdu radu a poucenie :)
#include <iostream>
#include <cstdio>
#include <map>
void main(void)
{
char str[10];
std::map< std::string, char > map_decode;
map_decode[".-"] = 'A'; map_decode["-----"] = '0';
map_decode["-..."] = 'B'; map_decode[".----"] = '1';
map_decode["-.-."] = 'C'; map_decode["..---"] = '2';
map_decode["-.."] = 'D'; map_decode["...--"] = '3';
map_decode["."] = 'E'; map_decode["....-"] = '4';
map_decode["..-."] = 'F'; map_decode["....."] = '5';
map_decode["--."] = 'G'; map_decode["-...."] = '6';
map_decode["...."] = 'H'; map_decode["--..."] = '7';
map_decode[".."] = 'I'; map_decode["---.."] = '8';
map_decode[".---"] = 'J'; map_decode["----."] = '9';
map_decode["-.-"] = 'K';
map_decode[".-.."] = 'L';
map_decode["--"] = 'M';
map_decode["-."] = 'N';
map_decode["---"] = 'O';
map_decode[".--."] = 'P';
map_decode["--.-"] = 'Q';
map_decode[".-."] = 'R';
map_decode["..."] = 'S';
map_decode["-"] = 'T';
map_decode["..-"] = 'U';
map_decode["...-"] = 'V';
map_decode[".--"] = 'W';
map_decode["-..-"] = 'X';
map_decode["-.--"] = 'Y';
map_decode["--.."] = 'Z';
while (1) {
scanf("%s", &str);
printf("%c", map_decode[str]);
}
}