解题思路:
注意事项:
参考代码:
#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(int x,int y){return x>y;}//降序求min
int main()
{
int n;cin>>n;
int max,min;
int count1=0,count2=0;
int a[1000],b[1000];
for(int i=0;i<n;i++)
{
cin>>a[i];
b[i]=a[i];
}
sort(a,a+n);//升序求max
for(int i=1;i<n;i++)
{
a[i]=a[i]*a[i-1]+1;
sort(a+i,a+n);
count1++;
}
max=a[count1];
sort(b,b+n,cmp);
for(int i=1;i<n;i++)
{
b[i]=b[i]*b[i-1]+1;
sort(b+i,b+n,cmp);
count2++;
}
min=b[count2];
cout<<max-min;
return 0;
}
0.0分
1 人评分
C语言程序设计教程(第三版)课后习题9.4 (C语言代码)浏览:718 |
【出圈】 (C语言代码)浏览:553 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:575 |
WU-字符串比较 (C++代码)浏览:754 |
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:798 |
C语言程序设计教程(第三版)课后习题6.6 (C++代码)浏览:624 |
哥德巴赫曾猜测 (C语言代码)浏览:2317 |
字符逆序 (C语言代码)浏览:609 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:551 |
有关字符,字符串的输入输出函数说明浏览:479 |