2123 - 求出最大整数
输入三个整数a, b, c, 求出其中最大的数!
Input
输入有很多行,每行有三个整数,分别用空格分离。
Output
输出每一行三个整数的最大值,每个输出一行。
Examples
Input
1 2 3 1 3 2
Output
3 3
Solution C
#include <stdio.h> void main(){ int max(int x,int y,int z); int a,b,c,dmax; while(scanf("%d %d %d",&a,&b,&c)!=EOF){ dmax=max(a,b,c); printf("%d\n",dmax); } } int max(int x,int y,int z) { int m ,n; if(x>y) m=x; else m=y; if(m>z) n=m; else n=z; return(n); }
Solution C++
#include<iostream> using namespace std; int main(){ int a,b,c,result; while(cin>>a>>b>>c){ if(a>b) result = a; else result = b; if(result<c) result = c; cout<<result<<endl; } return 0; }