Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- /* Homework Nov 19 Hyeong Rok Kim CS50 */
- int Compare(int x, int y, int z);
- // function to compare values
- int max = 0;
- int main()
- {
- int determiner, count, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r;
- printf("Enter numbers: "); //receiving number
- // comparing part
- 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
- Compare(max, a, count);
- Compare(max, b, count);
- Compare(max, c, count);
- Compare(max, d, count);
- Compare(max, e, count);
- Compare(max, f, count);
- Compare(max, g, count);
- Compare(max, h, count);
- Compare(max, i, count);
- Compare(max, j, count);
- Compare(max, k, count);
- Compare(max, l, count);
- Compare(max, m, count);
- Compare(max, n, count);
- Compare(max, o, count);
- Compare(max, p, count);
- Compare(max, q, count);
- Compare(max, r, count);
- }
- int Compare(int x, int y, int z)
- {
- // to do compare task with max value and input value
- // x for max, y for comparevalue
- if(y == 0)
- {
- printf("the largest number is %d", &x );
- printf("The occurrence count of the largest number is %d", &z);
- }
- else if (x < y)
- {
- z++;
- x = y;
- }
- return x, z;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement