思路:
水题,略过
Tip:
无
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 5; int ans[maxn]; int main() { int a, b, n; cin >> a >> b >> n; ans[1] = a; ans[2] = b; int lastt = 3; for (int i = 1; i <= n; i++) { if (lastt > n) break; int c = ans[i] * ans[i + 1]; if (c == 0) { ans[lastt++] = 0; continue; } stack<int> s; while (c) { s.push(c % 10); c /= 10; } while (!s.empty()) { ans[lastt++] = s.top(); s.pop(); } } bool first = true; for (int i = 1; i <= n; i++) { if (first) { first = false; cout << ans[i]; } else cout << " " << ans[i]; } return 0; }