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;
}

Advertisement

spot_img

Why Viral Kitchen Gadgets...

em> If you had told me six months ago that...

Why Viral Kitchen Gadgets...

em> I stumbled across this while desperately trying to fix...

Microsoft-Backed Space and Time...

In an era where enterprise adoption of autonomous workflows...

The Real Truth About...

em> I stumbled across this while desperately trying to fix...

How Viral Kitchen Gadgets...

em> If you had told me six months ago that...

Japanese bowling pioneer Ritsuko...

The sports world is mourning the loss of a...

Why Viral Kitchen Gadgets Is Currently Breaking the Internet

em> If you had told me six months ago that a single purchase would change how I approach my daily routine, I would not have...

Why Viral Kitchen Gadgets Is Currently Breaking the Internet

em> I stumbled across this while desperately trying to fix a recurring problem in my routine. The Viral Kitchen Gadgets was not even on my...

Microsoft-Backed Space and Time Launches Platform for AI Verification of Private Data

In an era where enterprise adoption of autonomous workflows is accelerating rapidly, data confidentiality remains one of the largest hurdles preventing organizations from unlocking...

The Real Truth About Viral Kitchen Gadgets Before You Buy

em> I stumbled across this while desperately trying to fix a recurring problem in my routine. The Viral Kitchen Gadgets was not even on my...

How Viral Kitchen Gadgets Is Quietly Changing the Game

em> If you had told me six months ago that a single purchase would change how I approach my daily routine, I would not have...

Japanese bowling pioneer Ritsuko Nakayama, first woman to bowl professional perfect game, dies at 84

The sports world is mourning the loss of a true trailblazer. Ritsuko Nakayama, the pioneering Japanese athlete who made history as the first woman...

I Tried Viral Kitchen Gadgets For 30 Days Here Is the Honest Truth

em> There comes a point when you realise that tolerating a frustrating situation is costing you more than just fixing it properly. That was the...

Tsai partner on sports as an asset class and bigger business behind Nets

When billionaire Joe Tsai initially acquired a 49 percent stake in the Brooklyn Nets in 2017 before taking complete ownership, the transaction signaled much...

Is Viral Kitchen Gadgets Worth Your Money Here Is Our Full Review

em> Most products in this category disappoint within weeks. Cheap materials, vague instructions, and results that fade fast. The Viral Kitchen Gadgets is a different...