- 336 名前: ◆/91kCCQXBo mailto:sage [2010/06/06(日) 00:14:15 ]
- #include<stdio.h>
int main(void){ int a=0, b=0, plus=1; char buf[80]; while(buf[0] != '='){ // fgets(buf,100,stdin); gets(buf); if(buf[0] == '+'){ plus = 1; b = a; } else if(buf[0] == '-'){ plus = -1; b = a; } else sscanf(buf, "%d", &a); } b = b + plus * a; printf("ans=%d\n", b); } /* 3 - 6 = ans=-3 */
|

|