Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct pais{
  5. string nome;
  6. int ouro, prata, bronze;
  7. };
  8.  
  9. pais participantes[300];
  10. int ind=-1;
  11. string prova, first, second, third;
  12.  
  13. bool cmp(pais a, pais b){
  14. return a.ouro > b.ouro;
  15. return a.prata > b.prata;
  16. return a.bronze > b.bronze;
  17. return a.nome > b.nome;
  18. }
  19.  
  20. int main(){
  21. while(getline(cin, prova) && prova!="b"){
  22. getline(cin, first);
  23. getline(cin, second);
  24. getline(cin, third);
  25.  
  26. bool found=false;
  27. int commit;
  28. for(int i=0;i<300;i++){
  29. if(participantes[i].nome==first){
  30. found=true;
  31. commit=i;
  32. break;
  33. }
  34. }
  35. if(!found){
  36. ind++;
  37. participantes[ind].nome=first;
  38. commit=ind;
  39. }
  40. participantes[commit].ouro++;
  41. //-----------------------------
  42. found=false;
  43. for(int i=0;i<300;i++){
  44. if(participantes[i].nome==second){
  45. found=true;
  46. commit=i;
  47. break;
  48. }
  49. }
  50. if(!found){
  51. ind++;
  52. participantes[ind].nome=second;
  53. commit=ind;
  54. }
  55. participantes[commit].prata++;
  56. //------------------------------
  57. found=false;
  58. for(int i=0;i<300;i++){
  59. if(participantes[i].nome==third){
  60. found=true;
  61. commit=i;
  62. break;
  63. }
  64. }
  65. if(!found){
  66. ind++;
  67. participantes[ind].nome=third;
  68. commit=ind;
  69. }
  70. participantes[commit].bronze++;
  71. }
  72.  
  73. sort(participantes, participantes+ind, cmp);
  74.  
  75. cout << "Quadro de Medalhas" << endl;
  76. for(int i=0;i<ind;i++){
  77. cout << participantes[i].nome << " " << participantes[i].ouro << " " << participantes[i].prata << " " << participantes[i].bronze << endl;
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement