注: 考虑两个数字乘积是0的情况。
#include <bits/stdc++.h>
using namespace std;
int res[10000];
int main() {
int a, b, c;
cin >> a >> b >> c;
res[0] = a;
res[1] = b;
int pos = 2;
for (int i = 0;; i++) {
int ans = res[i] * res[i + 1];
vector<int> tmp;
if (ans == 0) {
tmp.push_back(0);
}
else {
while (ans) {
tmp.push_back(ans % 10);
ans /= 10;
}
}
for (int j = tmp.size() - 1; j >= 0; j--) {
res[pos++] = tmp[j];
}
if (pos >= c) {
break;
}
}
int flag = 0;
for (int i = 0; i < c; i++) {
if (flag == 0) {
cout << res[i];
flag = 1;
}
else {
cout << " " << res[i];
}
}
return 0;
}
标签:tmp,080,L1,int,res,口诀,pos,++,ans
From: https://www.cnblogs.com/chengyiyuki/p/18105481