用指针方法求十个数最大和最小值之差输入格式输入十个整数每个整数之间用空格分隔输出格式为difference value=9输入样例为一二三四五六七八九十
时间: 2023-06-06 08:07:07 浏览: 179
任意输入10个数,最大最小调换后再输出
5星 · 资源好评率100%
```c++
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
int a[10];
for (int i = 0; i < 10; i++) {
scanf("%d", &a[i]);
}
int* maxNum = max_element(a, a+10);
int* minNum = min_element(a, a+10);
int diff = *maxNum - *minNum;
printf("difference value=%d", diff);
return 0;
}
```
阅读全文