接受两个周长 x 和 y 的递归函数.该函数应返回 x 乘以 y.i.e 的值,即 2*4=4+4=

a recursive function that accepts two perimeters x and y. The function should return the value of x times y.i.e 2*4=4+4=

本文关键字:的值 乘以 返回 两个 周长 递归函数 函数      更新时间:2023-10-16
#include<iostream>
using namespace std;
int times(int x ,int y)
{
   if(x==0){
      return y;
   }
   else{
      cout<< y+(x-1,y);
   }
}
int main()
{
   int x,y;
   cout<<"enter x :";
   cin>>x;
   cout<<"enter y: ";
   cin>>y;
   cout<< times(x,y);
   cout<<endl;`enter code here`
   return 0;
}
int times(int x ,int y)
{
   if(x==0){
      return 0;
   }
   return (y + times(x-1,y)); // This is your recursive call.
}