#include<iostream>
using namespace std;
string s1, s2;
int a[210], b[210], c[210];
void toi_reverse(int t[], string s) {
for (int i = 0; i < s.length(); i++)
{
t[s.length() - i] = s[i] - '0';
}
}
int main()
{
cin >> s1 >> s2;
toi_reverse(a, s1);
toi_reverse(b, s2);
int lena = s1.length(), lenb = s2.length();
int lenc = max(lena, lenb);
for (int i = 1; i <= lenc; i++) {
if (a[i] < b[i])
{
a[i + 1]--;
a[i] += 10;
}
c[i] = a[i] - b[i];
}
while (c[lenc] == 0 && lenc > 1) lenc--;
for (int i = lenc; i >= 1; i--) cout << c[i];
return 0;
}
高精度减法
最新推荐文章于 2024-08-31 22:41:09 发布