9Google AdSense

ACM Problem Solution 10696 - f91

problem

#include<stdio.h>

long int result(long int n)
{
  if(n<=100)
    return(result(result(n+11)));
  else if(n>=101)
    return(n-10);

}
int main()
{
long int n,x;
while(scanf("%ld",&n)==1)
{
    if(n==0)
        break;
    x=result(n);
    printf("f91(%ld) = %ld\n",n,x);

}
return 0;

}

No comments: