本帖最后由 jhq999 于 2022-5-25 16:59 编辑
借阁下的代码一用#include <iostream>
using namespace std;
int ch ,num ,i = 0;
int ary[100]={0};
void insertionSort()
{
int temp, k = 0;
for(;k < i;k++)if(ary[i-1]<ary[k])break;
for(;k < i-1;k++)
{
temp=ary[k];
ary[k]=ary[i-1];
ary[i-1]=temp;
}
}
int main(void) {
int a=0;
while (scanf("%d",&a))
{
ary[i]=a;
i++;
insertionSort();
}
for (int num: ary) {
cout << num << " ";
}
cout << endl;
cout
<< "最大值:" << ary[i-1] << endl
<< "最小值:" << ary[0] << endl;
return 0;
}
13 7 96 58 32 a
7 13 32 58 96 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
最大值:96
最小值:7
|