难的要si

ykj01 2021-12-21 20:24:43 0
#include<iostream>
using namespace std;

int main()
{
	int a[1010],n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	//1
	int sum=0;
	for(int i=1;i<=n;i++) sum+=a[i];
	cout<<sum<<endl;
	//2
	for(int i=n;i>=1;i--)  cout<<a[i]<<" ";
	cout<<endl;
	//3
	int max=a[1],maxi=1;
	for (int i=2;i<=n;i++)
	{
		if (a[i]>max)
		{
			max=a[i];
			maxi=i;
		}
	}
	cout<<max<<" "<<maxi<<endl;
	//4
	 int min=a[1],mini=1;
	for (int i=2;i<=n;i++)
	{
		if (a[i]<=min)
		{
			min=a[i];
			mini=i;
		}
	}
	cout<<min<<" "<<mini<<endl;
	return 0;
}

{{ vote && vote.total.up }}

共 2 条回复

ykj01

呵呵呵呵

ykj01