Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #include <iostream>
- #include <string.h>
- using namespace std;
- #define B 4
- const int n = 40;
- struct nap {
- char name[n];
- int goal;
- int assist;
- int penalty;
- };
- int _tmain(int argc, _TCHAR* argv[])
- {
- int C,A;
- cout << " Enter the number of players in the team (more than 4) ) \n" ;
- do {
- cin >> C ;
- while (C < 4);
- system ("cls");
- nap *a = new nap [C];
- nap *y = new nap [C];
- cout << "\n Enter hockey player's name \n\n" << endl;
- for (int i=0; i < C; i++)
- {
- cin.getline(a[i].name , n);
- a[i].goal = rand()%(10);
- a[i].assist = rand()%(3);
- a[i].penalty = rand()%(10)+10;
- }
- system ("cls");
- cout << endl;
- for (int i=0; i < c; i++) cout << a[i].name << " Goal:" << a[i].goal << " Assist:" << a[i].assist << " Penalty:" << a[i].penalty << endl ;
- int size = A+1;
- int i = 1;
- int j = 2;
- while (i < size)
- if (
- a[i - 1].goal + a[i-1].assist >= a[i].goal + a[i].assist )
- {
- i = j;
- j++;
- }
- else
- {
- y[i]=a[i-1];
- a[i-1] = a[i];
- a[i] = y[i];
- i = i - 1;
- if (i == 0)
- {
- i = j;
- j = j + 1;
- }
- }
- cout << "\n\n Top Player's \n";
- for (int i=0; i < B; i++) cout << a[i].name << " Goal:" << a[i].goal << " Assist:" << a[i].assist << " Penalty:" << a[i].penalty << endl ;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment