#include
using namespace std;
int max(int a[], int n)
{
int tmp = a[0];
for (int i = 0; i!=n; ++i)
if (tmp < a[i])
tmp = a[i];
return tmp;
}
int min(int a[], int n)
{
int tmp = a[0];
for (int i = 0; i!=n; ++i)
if (tmp > a[i])
tmp = a[i];
return tmp;
}
int main()
{
int *num = 0, len=0;
cout << "请输入数的个数:";
cin >> len;
num = new int[len];
cout << "请输入所有的数:";
for (int i = 0; i!=len; ++i)
cin >> num[i];
cout << "最大值为" << max(num, len) << endl;
cout << "最小值为" << min(num, len) << endl;
delete [] num;
return 0;
}
#include
using namespace std;
const int SIZE = 10;
int max(int* a, int size);
int min(int* a, int size);
int
main(){
int* a = new int [SIZE];
int Num = 0;
int MAX = 0;
int MIN = 0;
cout<<"Plz input the elements:";
for(int i = 0; cin>>a[i]; i++){
Num++;
}
MAX = max(a, Num);
MIN = min(a, Num);
cout<<"The max number in the array is: "<
delete [] a;
system("pause");
return 0;
}
int
max(int* a, int size){
int result = a[0];
for(int i = 1; i < size; i++){
if(result < a[i]){
result = a[i];
}
}
return result;
}
int
min(int* a, int size){
int result = a[0];
for(int i = 1; i < size; i++){
if(result > a[i]){
result = a[i];
}
}
return result;
}
给100分,帮你做。。