Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. string team[10]="";
  6. int score[10]={0};
  7. char x ;
  8. for(int i = 0 ; i < 10 ; i++){
  9. cout << "Enter Team " << (i+1) << " Name " << endl;
  10. cin >> team[i];
  11. cout << "Enter " << team[i] << "'s Score "<< endl;
  12. cin >> x ;
  13. switch (x){
  14. case 'W' :
  15. score[i]+=3;
  16. break;
  17. case 'D' :
  18. score[i]+=2;
  19. break;
  20. case 'F' :
  21. score[i]+=1;
  22. break;
  23.  
  24. }
  25. }
  26. int sw ; // swap scores
  27. string swname = ""; // swaped team's score swap
  28. for(int i = 0 ; i < 10 ; i++){
  29. for(int j = i+1 ; j < 10 ; j++){
  30. if(score[j] > score[i]){
  31. //swap Scores
  32. sw = score[i];
  33. score[i] = score[j];
  34. score[j]= sw;
  35. // swap teams name
  36. swname = team[i];
  37. team[i] = team[j];
  38. team[j]= swname;
  39. }
  40. }
  41. }
  42. for(int i = 0 ; i < 10; i++){
  43. cout << team[i] <<" team have " << score[i] << " point" <<endl;
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement