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

By | 2017-04-10T00:39:21+00:00 April 10th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#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 [...]