GGMPL

Untitled

Apr 6th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. #include <string>
  5. #include <map>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     ifstream input;
  11.     input.open("dane_geny.txt");
  12.     if(input.bad())
  13.     {
  14.         input.close();
  15.         input.open("dane_gen.txt");
  16.     }
  17.  
  18.     vector<string> gens;
  19.     string tmp;
  20.     while(input >> tmp)
  21.         gens.push_back(tmp);
  22.  
  23.     map<int, int> genotypes;
  24.     for(vector<string>::iterator i = gens.begin(); i != gens.end(); i++)
  25.     {
  26.         genotypes[i->length()]++;
  27.     }
  28.  
  29.     int maks = 0, cnt = 0;
  30.     for(map<int, int>::iterator i = genotypes.begin(); i != genotypes.end(); i++)
  31.     {
  32.         cnt++;
  33.         if(maks < i->second) maks = i->second;
  34.     }
  35.  
  36.     cout << cnt << " " << maks << endl;
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment