Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     string s, temps;
  9.     int i, j, n;
  10.     string names[100];
  11.     cout << "Enter N: ";
  12.     cin >> n;
  13.     temps.clear();
  14.  
  15.     for (i = 0; i < n; i++){
  16.         temps.clear();
  17.         getline(cin, s);
  18.         names[i] = s;
  19.                                                                                                
  20.         int tempi = s.length();
  21.         while (s[tempi] != ' '){
  22.             temps += s[tempi];
  23.             tempi--;
  24.         }
  25.         temps.erase(temps.find(' '));
  26.         cout << temps << endl;
  27.        
  28.         if (stoi(temps) < 1){
  29.             names[i] = nullptr;
  30.         }
  31.                
  32.     }
  33.    
  34.     for (i = 0; i < n; i++){
  35.         for(j = i+1; j < n; j++){
  36.             temps = names[i];
  37.             names[i] = names[j];
  38.             names[j] = temps;
  39.         }
  40.     }
  41.     for (int i = 0; i < 8; i++)
  42.     {
  43.         cout << names[i] << endl;
  44.     }
  45.  
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement