Professional Documents
Culture Documents
Using Namespace Bool Int Int If Return True If Return False If Return True If Return False Int If
Using Namespace Bool Int Int If Return True If Return False If Return True If Return False Int If
Using Namespace Bool Int Int If Return True If Return False If Return True If Return False Int If
if(result==1)
true;
if(result==0)
false;
return n;
}
int main() // The game starts when I give you some bears
{
int n;
bool result;
cout<< "please enter count of bears : ";
cin>>n;
result=bear(n);
if(result==true)
cout<< "true";
else
cout<<"false";
}
#include <iostream>
bool bear(int n)
{
int result,b,c;
result=2;
if(n==42) return true;
if(n!=42) return false;
if(result==1)return true;
if(result==0)return false;
int a;
a=n%5;
if(a==0&&result==2)result=bear(n-42);
a=n%4; // If n is divisible by 3 or 4, then you may multiply
the last two digits of n and //give back this many bears
if(a==0&&result==2)
{
b=n%10;
c=((n%100)-b)/10;
if(b!=0&&c!=0) result=bear(n-c*b);
}
a=n%3; // If n is divisible by 3 or 4, then you may multiply
the last two digits of n and // give back this many bears.
if(a==0&&result==2)
{
b=n%10;
c=((n%100)-b)/10;
if(b!=0&&c!=0)result=bear(n-c*b);
}
a=n%2; // If n is even, then you may give back exactly n/2
bears
if(a==0&&result==2) result=bear(n/2);
else if(result==2)return false;
if(result==1)return true;
if(result==0)return false;
}
int main() // The game starts when I give you some bears
{
int n;
bool result;
printf("please enter count of bears : ");
scanf("%d",&n);
result=bear(n);
if(result==true) printf(" true");
else printf(" false");
scanf("%d",&n);
}