ABBA's tribal leader does not know how to count. In exchange for one of his lands, another tribe asked him to choose one of three heaps of gold coins. But the ABBA's tribal leader wants to get as much as possible gold coins. Help the leader to make the right decision!
Note. The program has to use the pointer.
Input:
First-line contains 3 numbers that are not more than
10100
Output:
The maximum number of coins that can be taked.
Samples:
№ | INPUT | OUTPUT |
1 | 5 7 3 | 7 |
2 | 987531 234 86364 | 987531 |
3 | 189285 283 4958439238923098349024 | 4958439238923098349024 |
since the program is to be implemented using Pointers, I have used C language
#include<stdio.h>
int main(){
long long int num1,num2,num3;
long long int *ptr1,*ptr2,*ptr3;
scanf("%lld %lld %lld",&num1,&num2,&num3);
ptr1 = &num1;
ptr2 = &num2;
ptr3 = &num3;
if(*ptr1 > *ptr2) {
if(*ptr1 > *ptr3)
{
printf("%lld",*ptr1);
}
else{
printf("%lld",*ptr3);
}
}
else{
if(*ptr2 > *ptr3){
printf("%lld",*ptr2);
}
else{
printf("%lld",*ptr3);
}
}
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.