Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- string team[10]="";
- int score[10]={0};
- char x ;
- for(int i = 0 ; i < 10 ; i++){
- cout << "Enter Team " << (i+1) << " Name " << endl;
- cin >> team[i];
- cout << "Enter " << team[i] << "'s Score "<< endl;
- cin >> x ;
- switch (x){
- case 'W' :
- score[i]+=3;
- break;
- case 'D' :
- score[i]+=2;
- break;
- case 'F' :
- score[i]+=1;
- break;
- }
- }
- int sw ; // swap scores
- string swname = ""; // swaped team's score swap
- for(int i = 0 ; i < 10 ; i++){
- for(int j = i+1 ; j < 10 ; j++){
- if(score[j] > score[i]){
- //swap Scores
- sw = score[i];
- score[i] = score[j];
- score[j]= sw;
- // swap teams name
- swname = team[i];
- team[i] = team[j];
- team[j]= swname;
- }
- }
- }
- for(int i = 0 ; i < 10; i++){
- cout << team[i] <<" team have " << score[i] << " point" <<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement