Advertisement
nicb

Asd Ferone Lab5 MAP

Oct 17th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include<map>
  3. #include <fstream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     map<string, int> mappa;
  9.     fstream testo;
  10.     string appoggio;
  11.     bool trovato= false;
  12.     testo.open("testo.txt", ios::in);
  13.     while(!testo.eof())
  14.     {
  15.         testo>>appoggio;
  16.         for(map<string, int>::iterator it= mappa.begin(); it!=mappa.end(); it++)
  17.         {
  18.             if(it->first==appoggio)
  19.                 {
  20.                     it->second++;
  21.                     trovato=true;
  22.                 }
  23.         }
  24.         if(!false)
  25.         {
  26.             mappa.insert(pair <string, int>(appoggio,1));
  27.         }
  28.     }
  29.      for(map<string, int>::iterator it= mappa.begin(); it!=mappa.end(); it++)
  30.      {
  31.          cout<<"Parola: "<<it->first<<" Occ:"<<it->second;
  32.          cout<<endl;
  33.      }
  34.  
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement