蓝桥杯历届题目
还有6天蓝桥杯了 开始刷历届练习题了。 小计算器 题意 实现一个直接的计算器。没有四则运算规则优先级。并且能够有进制转换 题解 数字转换字符串的时候,$0$是关键点。 ac代码 #include using #define #define #define #define typedef typedef typedef const //head int const const char int char void memset ull t = k; int if while if ans[cnt++] = x%t+'0' }else ans[cnt++] = x%t+'A' } x/=t; } int rep(i,0 } char ull real_num int ull t = 0 ull cnt = 1 per(i,0 if t += cnt * (tt[i] - 'A' }else t += cnt * (tt[i] - '0' } cnt*= k; } return } int #ifdef freopen("1.in" #endif cin ull now = 0 int k = 10 bool rep(i,0 cin if now = 0 init = true }else cin ull temp = real_num(); if now = temp; init = false continue } if else else else else }else sign = 1 }else sign = 2 }else sign = 3 }else sign = 4 }else sign = 5 }else solve(now); cout }else cin } } return } 合根植物 题意 并查集 ...