https://i2.wp.com/eblogarithm.com/wp-content/uploads/2017/04/April-Fools-Contest-2017-problem-G-BF-Calculator-Solution-in-CC1.png?fit=640%2C360

April Fools Contest 2017, problem: (G) BF Calculator Solution in C/C++

#include<cstdio>
int main()
{
int ans=0,a=0; char c;
scanf(“%d”,&ans);
while (scanf(“%c%d”,&c,&a) != EOF)
{
if (c==’+’) ans+=a;
if (c==’-‘) ans-=a;
}
a=0;
if (ans==0)
{
printf(“++++++++++++++++++++++++++++++++++++++++++++++++.”);
return 0;
}
while (ans)
{
int x=ans%10;
for (int i=1;i<=x;i++) printf(“+”);
printf(“++++++++++++++++++++++++++++++++++++++++++++++++”);
printf(“>”);
ans/=10;
a++;
}
while (a–) printf(“<.”);
printf(“\n”);
return 0;
}

(Visited 38 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: