السلام ..
ممكن تساعدوني في الاسايمنت ؟
حليته بس الأول يطلع لي الاوت بوت كله يساوي 2
ماعرفت ليه ..
هذا السؤال
Question 1:
The Ackermann function is defined as follows for nonnegative integers m and n: long A(int, int);
Its value grows rapidly, even for small inputs. For example A(4,2) is an integer of 19,729 decimal digits
To test your function use the following main function
void main(){
cout<<"A(3,1)="<<A(3,1)<<endl;
cout<<"A(3,2)="<<A(3,2)<<endl;
cout<<"A(3,3)="<<A(3,3)<<endl;
}
The output
A(3,1)=13
A(3,2)=29
A(3,3)=61
اني الاوت بوت يطلع لي كلهم يساوي 2
الحل ..
#include<iostream>
using namespace std;
long A(int m, int n){
if(m==0) return n+1;
return(A(m-1,1));
return(A(m-1,A(m,n-1));
}
void main(){
cout<<"A(3,1)="<<A(3,1)<<endl;
cout<<"A(3,2)="<<A(3,2)<<endl;
cout<<"A(3,3)="<<A(3,3)<<endl;
}
السؤال الثاني
مادري ويش الايرور :ٍs
Question 2:
Write a recursive function CCO_Odd that counts and change to zero the odd numbers in an array of integer numbers. The function accepts as parameters an array of integer numbers and the array size.
The function should do the following
1. Changes any odd number in the array to zero.
2. counts the number of times odd numbers occurred in the array and returned.
3. Output the new array in same order
The function prototype is: int CountOdd(int arr[], int size);
#include<iostream>
using namespace std;
int CountOdd(int arr[], int size){
if(size==0) return 0;
if(arr]size-1[%2==1){
arr]size-1[=0;
CountOdd(arr,size-1);}
return (1+ CountOdd (arr,size-1));
else return (CountOdd(arr,size-1));
}
int main() {
int counter;
int list[15] = {15, 4, 20, 21, 28, 31, 17};
counter = CCO_Odd(list,7);
cout<<endl;
cout << "The number of odd integers in the original array is "<<counter<< endl;
return 0;
}
ساعدوني الدكتورة تبي الاسايمنت نطرشه الساعه 12
