// min_element/max_element example
#include <iostream> // std::cout
#include <algorithm> // std::min_element, std::max_element
using namespace std;
int main () {
int myints[] = {3,7,2,5,6,4,9};
// using default comparison:
cout << "The smallest element is " << *min_element(myints,myints+7) << '\n';
cout << "The largest element is " << max_element(myints,myints+7) << '\n';
return 0;
}
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(){
int a[10];
for(int i=0;i<10;i++){
a[i]=0;
}
int Max=*max_element(a,a+10);
printf("%d\n",Max);
return 0;
}
测试结果:
0