Advertisement
Visher

Untitled

Dec 11th, 2011
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <ctime>
  4. #include <vector>
  5. #include <windows.h>
  6.  
  7. using namespace std;
  8.  
  9. int main(int argc, char *argv[])
  10. {
  11.     srand(time(NULL));
  12.     vector <char> wyraz;
  13.     vector <char> pomieszany;
  14.     string input;
  15.     int znak;
  16.     cout << "Podaj wyraz" << endl;
  17.    
  18.     getline(cin, input);
  19.     for (int x = 0; x < input.length(); x++)
  20.         wyraz.push_back(input[x]);
  21.        
  22.     do
  23.     {
  24.         znak = rand() % wyraz.size();
  25.         pomieszany.push_back(wyraz[znak]);
  26.         wyraz.erase(wyraz.begin()+znak);
  27.     }
  28.     while (!wyraz.empty());
  29.    
  30.     for (int x = 0; x < pomieszany.size(); x++)
  31.         cout << pomieszany[x];
  32.    
  33.     cout << endl;
  34.     system("pause");
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement