#include <stdio.h>
int highcard (int array[])
{
int i, j;
int largest = array[0];
for (i=0; i<5; i++)
{
if (largest < array[i])
{
largest = array[i];
}
}
printf("largest element is %d", largest);
return largest;
}
int main()
{
int hand1[5]={8, 10, 6 , 4, 2};
int hand2[5]={13, 5, 3, 9, 12};
int largest;
highcard(hand1[5]);
int largest1 = largest;
return largest1;
highcard(hand2[5]);
int largest2 = largest;
return largest2;
if (largest1 < largest2)
{
printf("winner: hand2");
}
else
{
printf("winner: hand1");
}
return 0;
}
I am trying to develop a program that tiebreaks two highcard hands in poker. For this I "translate" the card values to numbers (2=2 ... A=14), and for this specific case the maximum array size will always be 5 (5 cards). My problem is how do I compare the return values of the same function when applied to two different arrays?
What I mean is:
- I have hand(array)1
- I have hand2
- I determine the largest number of hand1 and return it
- I do the same thing for hand2
- In main(), I want to compare the return (largest number) of highcard applied to hand1 and then hand2
But how do I specify in main() the specific return value of function highcard when applied to hand1 and then hand2 and keeping both returns separated?
This is what I have tried so far.
P.S.: This is for a university/college project, I have only started programming this semester, so any detailed explanation of my mistakes/errors and how to correct them would be very much appreciated :)