السلام عليكم ...
انا حليت هذا السوال ومو متاكدة اذا صح او لا
ممكن تصححونه لي لو فيه خطا
انا حاولت كذا محاولة
شوفو وش الصح
هذا السوال
Write a recursive function to find maximum value in an array?
Hint: The size of array=20, you must read the elements values from the user.
محاولاتي
1/
#include <iostream>
using namespace std;
int main()
{
int max (int size, int a[])
int i;
temp = a[0];
for (i = 0; i < size; i++)
if (a > temp)
temp = a;
return temp;
}
2/
#include <iostream>
using namespace std;
int main()
{
int j;
int size=20;
int nums[max];
int max_num = nums[0]
for(j=0 ; j<max ; j++)
max_num = max(max_num, nums[j]);
return 0;
}