Skip to content

Instantly share code, notes, and snippets.

@Biazus
Last active February 14, 2023 17:14
Show Gist options
  • Save Biazus/0b41243ea89ecabafa59 to your computer and use it in GitHub Desktop.
Save Biazus/0b41243ea89ecabafa59 to your computer and use it in GitHub Desktop.
Desafios: Aula 2, Atividade 2 (11062 - Andy's Second Dictionary)
//http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=22&page=show_problem&problem=2003
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <string.h>
#include <sstream>
#include <map>
using namespace std;
int main()
{
map<string, string> mymap;
string word;
char letra;
int index = 0, j=0;
while(1){
letra = getchar();
if(letra==EOF) break;
if ((letra >= 'A' && letra <= 'Z') || (letra >= 'a' && letra <= 'z') ){
letra=tolower(letra);
word+= letra;
}
else if(letra!='-' ){
if (word.length()){
mymap[word] = 1;
word.clear();
}
}
else{ //é um hifen
letra = getchar();
if(letra =='\n' ){
}
else{
if((letra >= 'A' && letra <= 'Z') || (letra >= 'a' && letra <= 'z') ){
word+= '-';
word+=letra;
}
else{
word+= '-';
mymap[word] = 1;
word.clear();
}
}
}
}
map<string, string>::iterator it;
for (map<string, string>::iterator it=mymap.begin(); it!=mymap.end(); ++it)
cout << it->first <<'\n';
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment