[luoguP1022] 计算器的改良(模拟)


传送门

超级大模拟。。

代码

#include <cstdio> #include <cstring> #include <iostream> #define isword(x) ((x) >= 'a' && (x) <= 'z') int n, a1, b1, a2, b2, f, x; char s[1001], c; int main() if(isdigit(s[i 1]) && i != 1) b1 += x * f; if(!isdigit(s[i 1]) && i != 1) if(s[i] == '+') f = 1; if(s[i] == '') f = 1; if(s[i] == '=') break; i++; } x = 0; while(isdigit(s[i])) x = (x << 1) + (x << 3) + s[i++] '0'; } i++; f = 1; while(i <= n) if(isdigit(s[i 1]) && s[i 1] != '=') b2 += x * f; if(!isdigit(s[i 1]) && s[i 1] != '=') if(s[i] == '+') f = 1; if(s[i] == '') f = 1; i++; } x = 0; while(isdigit(s[i])) x = (x << 1) + (x << 3) + s[i++] '0'; } if(isdigit(s[i 1])) b2 += x * f; if(!isdigit(s[i 1])) a1 = a2; b2 = b1; printf("%c=", c); if(b2 == 0) puts("0.000"); else printf("%.3lf\n", double(b2) / double(a1)); return 0; }

  



上一篇:[luoguP1098] 字符串的展开(模拟)

下一篇:[luoguP1019] 单词接龙(DFS)


模拟
Copyright © 2002-2019 k262电脑网 www.k262.cn 皖ICP备2020016292号
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!QQ:251442993 热门搜索 网站地图