Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <cctype>
- using namespace std;
- bool checkStudent(string arreglo[], string s, int &n){
- for(int i = 0; i < n; i++)
- if(arreglo[i] == s){
- for(int j = i; j < n-1; j++)
- arreglo[i] = arreglo[i+1];
- arreglo[n-1] = "";
- n--;
- return false;
- }
- return true;
- }
- int main ()
- {
- string s;
- int n, p, x;
- getline(cin, s);
- while(s != "0"){
- string arr[10100];
- n = 0; //cualquier string
- p = 0; //proyectos
- x = 0; //cuenta de proyectos
- while(s != "1"){
- if(isupper(s[0])){
- arr[n++] = s;
- p++;
- }
- else
- if(checkStudent(arr, s, n))
- arr[n++] = s;
- getline(cin, s);
- }
- pair<int, string> buenos[p];
- for(int i = 0; i < n; i++)
- if(isupper(arr[i][0])){
- buenos[x].first = 0;
- buenos[x++].second == arr[i];
- }
- else buenos[x-1].first++;
- sort(buenos, buenos + p);
- for(int i = 0; i < p; i++)
- cout << buenos[i].first << " " << buenos[i].second << endl;
- getline(cin, s);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement