code:
#include<stdio.h> int findMax(int a,int b,int c) { int max; if(a>=b && a>=c) return a; else if(b>=a && b>=c) //if any two value same then >= is using ike 55 7 55 then 55 is the answer return b; else if(c>=a && c>=b) return c; } int main() { int a,b,c; while(scanf("%d %d %d",&a,&b,&c)!=EOF) { int t=findMax(a,b,c); printf("%d\n",t); } return 0; }
Another Logic by me:
#include<stdio.h> int findMax(int a,int b,int c) { int max; if(a>b && a>c) max=a; else if(b>a && b>c) max=b; else if(c>a && c>b) max=c; else max=a; return max; } int main() { int a,b,c; while(scanf("%d %d %d",&a,&b,&c)!=EOF) { int t=findMax(a,b,c); printf("%d\n",t); } return 0; }
Another Logic that is good:
//it's a good logic i think test case for this 8 8 3 and it return 8 #include<stdio.h> int findMax(int a,int b,int c) { int max; if(a>b) return a; else if(b>c) return b; else return c; } int main() { int a,b,c; while(scanf("%d %d %d",&a,&b,&c)!=EOF) { int t=findMax(a,b,c); printf("%d\n",t); } return 0; }
A very very good logic: (Logic Logic)
#include<stdio.h> int add(int c) { int max; int i,j; int ara[3]; for(i=0; i<3; i++){ scanf("%d",&ara[i]); } max=ara[0]; for(i=0; i<3; i++) { if(ara[i]>=max) //max<=ara[i] { max=ara[i]; } } //c=max; return max; } int main() { int ans; int c; ans=add(c); printf("%d\n",ans); return 0; }
#include<stdio.h> int add(int c) { int max; int i,j; int ara[3]; for(i=0; i<3; i++){ scanf("%d",&ara[i]); } max=ara[0]; for(i=0; i<3; i++) { if(ara[i]>=max) //max<=ara[i] { max=ara[i]; } } //c=max; return max; } int main() { int ans; int c; ans=add(c); printf("%d\n",ans); return 0; }