⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example 6_1.cpp

📁 data+structures+using+c的源码
💻 CPP
字号:
//Largest Element in an Array

#include <iostream>

using namespace std;

int largest(const int list[], int lowerIndex, int upperIndex);

int main()
{
	int intArray[10] = {23, 43, 35, 38, 67, 12, 76, 10, 34, 8};

	cout<<"The largest element in intArray: "
	    <<largest(intArray,0,9);
	cout<<endl;

	return 0;
}

int largest(const int list[], int lowerIndex, int upperIndex)
{
   int max;

   if(lowerIndex == upperIndex)   //the size of the sublist is 1
   		return list[lowerIndex];
   else
   {
		max = largest(list, lowerIndex + 1, upperIndex); 
		if(list[lowerIndex] >= max)
			return list[lowerIndex];
		else
			return max;
   }
}

⌨️ 快捷键说明

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