<mosaic.cnfolio.com>
PROGRAM
  1. /*START/*
  2. /*Define function Bubblesort()*/
  3. /*data type player1[10], player 2[10]*/
  4. /*data type winner;*/
  5. /*intialize i=0, i=0,*/
  6. /*Define function Bubblesort(player1, m)*/
  7. /*Define function Bubblesort(player2, n)*/
  8. /*WHILE i is less than m and n*/
  9. /*IF player1[i] > player2[i]*/
  10. /*Winner=1 and break*/
  11. /*ELSE IF (player[i] < player2[i]*/
  12. /*Winner = 2 and break*/
  13. /*IF winner == 0*/
  14. /*IF (i<m)*/
  15. /*Winner = 1*/
  16. /*ELSE IF (I < n)*/
  17. /*Winner = 2*/
  18. /*IF output == 0 output “Draw”*/
  19. /*ELSE IF == 1 output “Player 1 wins”*/
  20. /*ELSE*/
  21. /*Output “player 2 wins”*/
  22. /*Define function void bubblesort()*/
  23. /*Initialize c=0, d=0,*/
  24. /*swap = a[d]*/
  25. /*IF a[d] > a[d+1]*/
  26. /*a[d+1] = swap*/
  27. /*END*/
  28.  
  29. #include <stdio.h>
  30. void bubblesort(int a[], int n);
  31. int main(void)
  32. {
  33. int player1[10], m;
  34. int player2[10], n;
  35. int winner;
  36. int i;
  37. scanf("%d", &m);
  38. for (i = 0; i < m; i++)
  39. scanf("%d", &player1[i]);
  40. bubblesort(player1, m);
  41. scanf("%d", &n);
  42. for (i = 0; i < n; i++)
  43. scanf("%d", &player2[i]);
  44. bubblesort(player2, n);
  45. i = 0;
  46. winner = 0;
  47. while (i < m && i < n)
  48. {
  49. if (player1[i] > player2[i])
  50. {
  51. winner = 1;
  52. break;
  53. }
  54. else if (player1[i] < player2[i])
  55. {
  56. winner = 2;
  57. break;
  58. }
  59. i++;
  60. }
  61. if (winner == 0)
  62. {
  63. if (i < m)
  64. winner = 1;
  65. else if (i < n)
  66. winner = 2;
  67. }
  68. if (winner == 0)
  69. {
  70. printf("Draw\n");
  71. }
  72. else if (winner == 1)
  73. {
  74. printf("Player 1 wins\n");
  75. }
  76. else
  77. {
  78. printf("Player 2 wins\n");
  79. }
  80.  
  81. return 0;
  82. }
  83. void bubblesort(int a[], int n)
  84. {
  85. int c, d, swap;
  86. for (c = 0; c < (n - 1); c++)
  87. {
  88. for (d = 0; d < n - c - 1; d++)
  89. {
  90. if (a[d] < a[d+1])
  91. {
  92. swap = a[d];
  93. a[d] = a[d+1];
  94. a[d+1] = swap;
  95. }
  96. }
  97. }
  98. }