Don't like ads? PRO users don't see any ads ;-)
Guest

te putarra

By: a guest on May 8th, 2012  |  syntax: None  |  size: 0.60 KB  |  hits: 42  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. struct Persona {
  7.         string nom;
  8.         bool dona;
  9.         int edat;
  10. };
  11.  
  12. int main() {
  13.         int n, aux;
  14.         aux = 0;
  15.         cin >> n;
  16.         vector<Persona> llista(n);
  17.         string sexe;
  18.         for (int i = 0; i < n; ++i) {
  19.                 cin >> llista[i].nom >> sexe >> llista[i].edat;
  20.                 if (sexe == "dona") llista[i].dona = true;
  21.                 else {
  22.                         llista[i].dona = false;
  23.                         if (llista[i].edat > aux) aux = llista[i].edat;
  24.                 }
  25.         }
  26.         for (int i = 0; i < n; ++i) {
  27.                 if (llista[i].dona and llista[i].edat < aux) cout << llista[i].nom << " " << llista[i].edat << endl;   
  28.         }
  29. }