用C++函數(shù)描述個算法,并求出時間復(fù)雜度
2 回答

繁華開滿天機(jī)
TA貢獻(xiàn)1816條經(jīng)驗 獲得超4個贊
#include<iostream.h>
int max=0,may=0;
int array[5][5];
void ReMax()
{
int i,j;
///冒泡法,時間復(fù)雜度為5*5
for(i=0;i<5;i++)
for(j=0;j<5;j++)
if(array[max][may]<array[i][j+1]){max=i;may=j+1;}
}
void main(){
int i,j;
//*a=(int*)malloc(5*sizeof(int));
cout<<"請輸入一個數(shù)組array[5][5]:"<<endl;
for(i=0;i<5;i++)
for(j=0;j<5;j++)
cin>>array[i][j];
ReMax();
cout<<"最大值坐標(biāo):"<<max<<","<<may<<endl;
}
- 2 回答
- 0 關(guān)注
- 619 瀏覽
添加回答
舉報
0/150
提交
取消