相加和最大值
Time Limit: 1000MS
Memory Limit: 65536KB
Problem Description
输入三个整数a,b,c。并进行两两相加,最后比较相加和的最大值。
Input
输入数据包含三个整数,用空格分开。
Output
输出两两相加后的最大值。
Example Input
1 2 3
Example Output
5
解题思路:跟三个数找最大值原理一样,就是把这个三个数其中每个都是另外两个数的和,如a=e+f,然后再找最大值即可
#include<stdio.h> int main() { int a, b, c, e, f, g, d; scanf("%d %d %d",&e, &f, &g); a = e + f; b = e + g; c = f + g; d=0; if(a < b) { d = b; } else { d = a; } if(d > c) { printf("%d\n",d); } else { printf("%d\n",c); } return 0; }