Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cctype>
  4.  
  5. using namespace std;
  6.  
  7. bool checkStudent(string arreglo[], string s, int &n){
  8.     for(int i = 0; i < n; i++)
  9.         if(arreglo[i] == s){
  10.             for(int j = i; j < n-1; j++)
  11.                 arreglo[i] = arreglo[i+1];
  12.             arreglo[n-1] = "";
  13.             n--;
  14.             return false;
  15.         }
  16.     return true;
  17. }
  18.  
  19. int main ()
  20. {
  21.     string s;
  22.     int n, p, x;
  23.     getline(cin, s);
  24.     while(s != "0"){
  25.         string arr[10100];
  26.         n = 0; //cualquier string
  27.         p = 0; //proyectos
  28.         x = 0; //cuenta de proyectos
  29.         while(s != "1"){
  30.  
  31.             if(isupper(s[0])){
  32.                 arr[n++] = s;
  33.                 p++;
  34.             }
  35.             else
  36.                 if(checkStudent(arr, s, n))
  37.                     arr[n++] = s;
  38.             getline(cin, s);
  39.         }
  40.  
  41.  
  42.         pair<int, string> buenos[p];
  43.         for(int i = 0; i < n; i++)
  44.             if(isupper(arr[i][0])){
  45.                 buenos[x].first = 0;
  46.                 buenos[x++].second == arr[i];
  47.             }
  48.             else buenos[x-1].first++;
  49.  
  50.         sort(buenos, buenos + p);
  51.  
  52.         for(int i = 0; i < p; i++)
  53.             cout << buenos[i].first << " " << buenos[i].second << endl;
  54.  
  55.         getline(cin, s);
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement