Moderador: ivancp

- uno
- dos
- uno
- tres
- cinco
- cuatro
- cinco
-
- #include <map>
- #include <string>
- #include <iostream>
-
- using namespace std;
-
- int main(int argc, char *argv[])
- {
- map<string,int> tabla;
-
- string input;
-
- //ingresando los datos
- while(cin>>input)
- tabla[input] = tabla[input] + 1;
-
- // mostrando las entradas
- cout<<"Lista de elementos:\n";
-
- for(map<string,int>::iterator i = tabla.begin(); i != tabla.end() ; i++)
- {
- cout<<i->first<<" : "<<i->second<<endl
- }
- }
-
-
- c:\cpp\prueba.exe < input.txt
- uno : 2
- dos : 1
- tres : 1
- cuatro : 1
- cinco : 2
-

Usuarios navegando por este Foro: Google [Bot] y 0 invitados