?? cpp1.cpp
字號:
#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 + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -