Windows平台下GCC编程之从键盘输入3个整数,求其中的最大数和最小数,并输出结果
来源:互联网 发布:ping的端口是多少 编辑:程序博客网 时间:2024/05/17 09:02
代码都是我自己练习写的,如果有什么不妥,自己修改就行了,在Code::Blocks16.01+GCC4.9.2 for Windows上编译运行成功
//1. 从键盘输入3个整数,求其中的最大数和最小数,并输出结果。#include<iostream>using namespace std;void getMaxMin(int a,int b, int c);int main(int argc, char *argv[]){ int a,b, c; cout<<"Please input 3 numbers:"; cin>>a>>b>>c; getMaxMin(a,b,c); return 0;}void getMaxMin(int a,int b, int c){ int max=a; int min=b; if(a>b&&b>c) { max=a; min=c; cout<<"The max number is :"<<max<<endl; cout<<"The min number is :"<<min<<endl; } else if(a>b&&b<c) { if(a>c) { max=a; min=b; } else if(a<c) { max=c; min=b; } cout<<"The max number is :"<<max<<endl; cout<<"The min number is :"<<min<<endl; } else if(b>a&&a>c) { max=b; min=c; cout<<"The max number is :"<<max<<endl; cout<<"The min number is :"<<min<<endl; } else if(b>a&&a<c) { if(b>c) { max=b; min=a; } else if(b<c) { max=c; min=a; } cout<<"The max number is :"<<max<<endl; cout<<"The min number is :"<<min<<endl; } else if(c>a&&a>b) { max=c; min=b; cout<<"The max number is :"<<max<<endl; cout<<"The min number is :"<<min<<endl; } else if(c>a&&a<b) { if(c>b) { max=c; min=a; } else if(c<b) { max=b; min=a; } cout<<"The max number is :"<<max<<endl; cout<<"The min number is :"<<min<<endl; }}
0 0
- Windows平台下GCC编程之从键盘输入3个整数,求其中的最大数和最小数,并输出结果
- Windows平台下GCC编程之从键盘上输入一个3*3的整数矩阵,求其各行的平均值并输出,输出时保留两位小数
- Windows平台下GCC编程之从键盘输入10个数,要求输出其中最小的。
- Windows平台下GCC编程之根据输入的运算符对两个数计算,并输出结果
- Windows平台下GCC编程之反向输出整数
- Windows平台下GCC编程之从键盘上输入一个3*4的整数矩阵,要求输出其最大元素的值,以及它的行号和列号
- 习题 4.4 有3个整数a,b,c,由键盘输入,输出其中最大的数。
- 从键盘任意输入10个整数,用函数编程实现将其中最大数与最小数的位置对换后,再输出调整后的数组。
- 从键盘输入10个实数,并输出它们的平均数和比平均数大的数
- Windows平台下GCC编程之从键盘输入12个数存入二维数组a[3][4]中,编写程序求出最大元素的值及它所在的行号和列号。
- 从键盘输入某个十进制整数数,转换成对应的二进制整数并输出。
- 有n个32位无符号整数,求其中异或之后结果最大的两个数
- 3个整数中最大的数和最小的数
- 从键盘输出3个整数,输出最大的一个数
- 设计一个从5个整数中取最小数和最大数的程序---acm题目
- 从键盘输入十个整数存入一维数组中,求出其中的最大数并输出(要求用指针访问数组元素)?
- java编程基础篇 --> 从键盘输入一个整数(1 个 3 位整数),判断其是不是水仙花数。所谓“水仙花数”是 指一个 3 位数,其各位数字立方和等于该数本身。
- 在一N个整数查找序列中的最大数和最小数, 及 所需要的比较次数?
- hadoop常见问题Browse the filesystem链接打不开
- 三、测试用例
- ionic ios archive error Cordova/CDVViewController.h
- java 中\b \t \n \f \r \" \
- Hive实现wordCount程序
- Windows平台下GCC编程之从键盘输入3个整数,求其中的最大数和最小数,并输出结果
- collections 模块功能用例
- hive优化原则
- 理想的程序员
- hive优化思路
- PAT乙级 1005.继续(3n+1)猜想 (25)
- 使用HIVE注意点
- 状态栏 导航栏 tabbar背景色&字体颜色设置
- 彻底理解KMP算法