利用指针求最值
2015-07-18 23:48
246 查看
[code]#include <iostream> using namespace std; int getmaxormin(int *arr,int count,bool isMax) { int temp=arr[0]; for(int i=1;i<count;i++) { if(isMax) { if(temp<arr[i])temp=arr[i]; } else { if(temp>arr[i])temp=arr[i]; } } return temp; } int main() { bool isMax=false; int arr[10],i; for(i=0;i<10;i++) cin>>arr[i]; cout<<"求最大值输入1,最小值输0\n"; cin>>isMax; cout<<getmaxormin(arr,10,isMax)<<'\n'; return 0; }
相关文章推荐
- Mac下Android studio 之NDK配置教程
- 组队选拔赛01 ---- trener
- Android 开发有哪些新技术出现?
- 协同函数的脚本编写
- HDU 2639 Bone Collector II(01背包 求第k大)
- Java基础学习之内部类
- python标准库:collections和heapq模块
- python模块 - collections模块
- LeetCode Single Number (找不不重复元素)
- 存储学习笔记第一节
- C++ Primer快速入门之五:实用的模板库
- winform中的dateTimePicker控件怎么设置它的默认值为空
- 《JavaScript设计模式与开发实践》读书笔记之模板方法模式
- linux下Oracle自启动配置及启动脚本 12c 测试通过
- linux下helloworld的简单编译过程
- 二维数组的选择排序
- PHP,C++,Mysql
- 2015071805 - 所有的都是体验
- [BZOJ1036][ZJOI2008]树的统计Count
- 2015.07.18总结