Advertisement
Guest User

Untitled

a guest
May 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. void Deck::salvar_deck(string filename)
  2. {
  3.     ofstream file;
  4.     string linha;
  5.     vector<int> quantidade(26,0);
  6.  
  7.     cout << "\nDeck: " << _deck << endl << endl;
  8.  
  9.     cout << "\nVector das quantidades antes:\n";
  10.     for (size_t i = 0; i < quantidade.size(); i++)
  11.         cout << quantidade[i] << endl;
  12.  
  13.     for (size_t i = 0; i < _deck.size(); i++)
  14.     {
  15.         if (_deck[i] == '_')
  16.             ++quantidade[26];
  17.         else
  18.             ++quantidade[_deck[i] - 'A'];
  19.     }
  20.  
  21.     cout << "\n\nVector das quantidades depois:\n";
  22.     for (size_t i = 0; i < quantidade.size(); i++)
  23.         cout << quantidade[i] << endl;
  24.  
  25.     // Pausa
  26.     cin.get();
  27.     file.open (filename.c_str());
  28.  
  29.     for (int g = 0; g < 27 ; ++g) {
  30.         linha = "";
  31.         if (g != 27) {
  32.             file << "\n" << char ('A' + g) << " "
  33.                  << quantidade['A' + g] << " " << scores[g];
  34.         } else {
  35.             file << "\n" << "_" << " " << quantidade[26]
  36.             << " " << scores[27];
  37.         }
  38.     }
  39.     file.close();
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement