SDUT 1154 求三个整数的最大值
来源:互联网 发布:c语言200种游戏源代码 编辑:程序博客网 时间:2024/06/05 19:22
Problem Description
请编写程序,输入三个整数,求出其中的最大值输出。
Input
在一行上输入三个整数,整数间用逗号分隔。
Output
输出三个数中的最大值。
Example Input
5,7,9
Example Output
max=9
答案:
#include<iostream>#include<stdio.h>using namespace std;int main() {int a, b, c, temp, max;scanf("%d, %d, %d",&a, &b, &c);//使用C中的scanf输入函数可以达到输入之间逗号隔开if(a > b)temp = a;elsetemp = b;if(temp > c)max = temp;elsemax = c;cout<<"max="<<max<<endl;return 0;}或者是:(纯C++版本,但比较繁琐)
#include<iostream>#include<stdio.h>using namespace std;int main() {int a, b, c, temp, max;cin>> a;if (cin.get()==',' ) //如果不按 数字+逗号+数字格式输入,则不允许输入第二个数,以达到限制要求 否则,用户输入数字+空格+数字也能达到输入两个数字 { cin>>b ; }if (cin.get()==',' ) //如果不按 数字+逗号+数字格式输入,则不允许输入第二个数,以达到限制要求 否则,用户输入数字+空格+数字也能达到输入两个数字 { cin>>c ; }if(a > b)temp = a;elsetemp = b;if(temp > c)max = temp;elsemax = c;cout<<"max="<<max<<endl;return 0;}
阅读全文
0 0
- SDUT 1154 求三个整数的最大值
- 求三个整数的最大值
- C语言实验——求三个整数的最大值 (sdut oj)
- 上机项目--求三个整数的最大值
- java求三个整数的最大值
- 求三个整数中的最大值
- 用指针编写一函数求三个整数的最大值
- C语言实验——求三个整数的最大值
- JAVA_ 求三个整数的最大值(split()用法)
- C语言实验——求三个整数的最大值
- C语言实验——求三个整数的最大值
- 编程:求三个整数中的最大值
- 求三个整数最大值(程序)
- 假期练习--求三个整数中的最大值
- 输出三个整数的最大值
- 1021: 三个整数的最大值
- 求三个数的最大值
- 求三个数的最大值
- Java局部内部类
- 模拟PROBLEM的后面两题 动态规划
- LeetCode Algorithms 210. Course Schedule II
- poj-2393-Yogurt Factory
- dispose 和 null区别
- SDUT 1154 求三个整数的最大值
- LeetCode 453.Minimum Moves to Equal Array Elements
- Hololens模拟器的安装配置
- ORACLE锁等待的处理方法
- 《算法》第4版(Algorithms Fourth Edition)在Eclipse下的重定向与管道问题
- 面向对象
- 2017-06-11 Padavan 完美适配newifi mini【adbyby+SS+KP ...】youku L1 /小米mini
- 文章标题
- Java中MVC详解以及优缺点总结