Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #include <math.h>
  4.  
  5. /* Homework Nov 19 Hyeong Rok Kim CS50 */
  6.  
  7. int Compare(int x, int y, int z);
  8.  
  9. // function to compare values
  10.  
  11. int max = 0;
  12.  
  13. int main()
  14. {
  15. int determiner, count, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r;
  16.  
  17.  
  18. printf("Enter numbers: "); //receiving number
  19.  
  20. // comparing part
  21.  
  22. scanf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", &a, &b, &c, &d, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q, &r); // receive input
  23.  
  24. Compare(max, a, count);
  25. Compare(max, b, count);
  26. Compare(max, c, count);
  27. Compare(max, d, count);
  28. Compare(max, e, count);
  29. Compare(max, f, count);
  30. Compare(max, g, count);
  31. Compare(max, h, count);
  32. Compare(max, i, count);
  33. Compare(max, j, count);
  34. Compare(max, k, count);
  35. Compare(max, l, count);
  36. Compare(max, m, count);
  37. Compare(max, n, count);
  38. Compare(max, o, count);
  39. Compare(max, p, count);
  40. Compare(max, q, count);
  41. Compare(max, r, count);
  42.  
  43.  
  44. }
  45.  
  46. int Compare(int x, int y, int z)
  47. {
  48. // to do compare task with max value and input value
  49. // x for max, y for comparevalue
  50. if(y == 0)
  51. {
  52. printf("the largest number is %d", &x );
  53.  
  54. printf("The occurrence count of the largest number is %d", &z);
  55.  
  56. }
  57. else if (x < y)
  58. {
  59. z++;
  60. x = y;
  61. }
  62.  
  63. return x, z;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement