Guest User

Untitled

a guest
May 28th, 2011
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include <math.h>
  2. #include <iostream>
  3. #include <string.h>
  4.  
  5. using namespace std;
  6.  
  7. #define B 4
  8.  
  9. const int n = 40;
  10.  
  11. struct nap {
  12. char name[n];
  13. int goal;
  14. int assist;
  15. int penalty;
  16. };
  17.  
  18. int _tmain(int argc, _TCHAR* argv[])
  19. {
  20. int C,A;
  21. cout << " Enter the number of players in the team (more than 4) ) \n" ;
  22.  
  23. do {
  24. cin >> C ;
  25. while (C < 4);
  26.  
  27. system ("cls");
  28.  
  29. nap *a = new nap [C];
  30. nap *y = new nap [C];
  31. cout << "\n Enter hockey player's name \n\n" << endl;
  32.  
  33. for (int i=0; i < C; i++)
  34. {
  35. cin.getline(a[i].name , n);
  36. a[i].goal = rand()%(10);
  37. a[i].assist = rand()%(3);
  38. a[i].penalty = rand()%(10)+10;
  39. }
  40.  
  41. system ("cls");
  42. cout << endl;
  43.  
  44. for (int i=0; i < c; i++) cout << a[i].name << " Goal:" << a[i].goal << " Assist:" << a[i].assist << " Penalty:" << a[i].penalty << endl ;
  45.  
  46. int size = A+1;
  47. int i = 1;
  48. int j = 2;
  49. while (i < size)
  50. if (
  51. a[i - 1].goal + a[i-1].assist >= a[i].goal + a[i].assist )
  52. {
  53. i = j;
  54. j++;
  55. }
  56. else
  57. {
  58. y[i]=a[i-1];
  59. a[i-1] = a[i];
  60. a[i] = y[i];
  61. i = i - 1;
  62. if (i == 0)
  63. {
  64. i = j;
  65. j = j + 1;
  66. }
  67. }
  68. cout << "\n\n Top Player's \n";
  69. for (int i=0; i < B; i++) cout << a[i].name << " Goal:" << a[i].goal << " Assist:" << a[i].assist << " Penalty:" << a[i].penalty << endl ;
  70.  
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment