求助啊,五个点,四个过,一个直接re,不懂啊
查看原帖
求助啊,五个点,四个过,一个直接re,不懂啊
1509877
lingyi_ling楼主2024/12/8 13:55
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;int as[1005], bs[1005], c[2005];int main  () {	string a, b;
	cin >> a >> b;reverse(a.begin(), a.end());reverse(b.begin(), b.end());int la = a.size();int lb = b.size();
	for (int i = 0; i < la; i++) {
		as[i] = a[i] - 48;
	}
	for (int i = 0; i < lb; i++) {
		bs[i] = b[i] - 48;
	}
	for (int i = 0; i <= la; i++) {
		for (int j = 0; j <= lb; j++) {
			c[i + j] = c[i + j] + as[i] * bs[j];
		}
	}
	for (int i = 0; i <= 2000; i++) {
		if (c[i] > 9) {
			c[i + 1] += c[i] / 10;
			c[i] %= 10;
		}
	}
	int i = 2000;
	while (c[i] == 0 && i != 0) {
		i--;
	}
	for (int j = i; j >= 0; j--) {
		cout << c[j];
	}
	return 0;
}
2024/12/8 13:55
加载中...