|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 Ray-先生 于 2021-10-10 19:55 编辑
- #include <iostream>
- #include <cstdio>
- #include <vector>
- #include <string>
- using namespace std;
- vector <int> a, b;
- string ta, tb;
- vector <int> sub()
- {
- vector <int> ans;
- int t = 0;
- for (int i = 0; i < a.size() || i < b.size(); i++)
- {
- if (i < a.size()) t += a[i];
- if (i < b.size()) t -= b[i];
- if (t < 0)
- {
- t += 10;
- a[i + 1] -= 1;
- }
- ans.push_back(t % 10);
- t = 0;
- }
- return ans;
- }
- int main()
- {
- cin >> ta;
- for (int i = ta.size() - 1; i >= 0; i--);
- a.push_back(ta[i] - '0');
- cin >> tb;
- for (int i = tb.size() - 1; i >= 0; i--)
- b.push_back(tb[i] - '0');
- vector <int> ans=sub();
- for (int i = ans.size() - 1; i >= 0; i--)
- printf("%c", ans[i]);
- return 0;
- }
复制代码
Visual Studio 2022 Preview在第30行报错E0020未定义标识符"i"和C2065"i":未声明标识符 |
|