cpp1.cpp

来自「ACM国际大学生程序设计竞赛(英文全称:ACM International Co」· C++ 代码 · 共 24 行

CPP
24
字号
#include<iostream.h>
double f(int x,int y,double a[])//求a[x]到a[y]的最大值
{
	if(x==y) return a[x];
	else
	{
		double m=f(x,(x+y)/2,a)>f((x+y)/2+1,y,a)?f(x,(x+y)/2,a):f((x+y)/2+1,y,a);
		return m;
	}
}
void main()
{
	int n;
	cout<<"input the number of data   ";
	cin>>n;
	double *a=new double[n];
    cout<<"input the value of data   ";
    for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cout<<"the max of the data is "<<f(0,n-1,a)<<endl;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?