Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- struct pais{
- string nome;
- int ouro, prata, bronze;
- };
- pais participantes[300];
- int ind=-1;
- string prova, first, second, third;
- bool cmp(pais a, pais b){
- return a.ouro > b.ouro;
- return a.prata > b.prata;
- return a.bronze > b.bronze;
- return a.nome > b.nome;
- }
- int main(){
- while(getline(cin, prova) && prova!="b"){
- getline(cin, first);
- getline(cin, second);
- getline(cin, third);
- bool found=false;
- int commit;
- for(int i=0;i<300;i++){
- if(participantes[i].nome==first){
- found=true;
- commit=i;
- break;
- }
- }
- if(!found){
- ind++;
- participantes[ind].nome=first;
- commit=ind;
- }
- participantes[commit].ouro++;
- //-----------------------------
- found=false;
- for(int i=0;i<300;i++){
- if(participantes[i].nome==second){
- found=true;
- commit=i;
- break;
- }
- }
- if(!found){
- ind++;
- participantes[ind].nome=second;
- commit=ind;
- }
- participantes[commit].prata++;
- //------------------------------
- found=false;
- for(int i=0;i<300;i++){
- if(participantes[i].nome==third){
- found=true;
- commit=i;
- break;
- }
- }
- if(!found){
- ind++;
- participantes[ind].nome=third;
- commit=ind;
- }
- participantes[commit].bronze++;
- }
- sort(participantes, participantes+ind, cmp);
- cout << "Quadro de Medalhas" << endl;
- for(int i=0;i<ind;i++){
- cout << participantes[i].nome << " " << participantes[i].ouro << " " << participantes[i].prata << " " << participantes[i].bronze << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement