PAT-BASIC1086——就不告诉你

xiaoxiao2025-05-02  9

我的PAT-BASIC代码仓:https://github.com/617076674/PAT-BASIC

原题链接:https://pintia.cn/problem-sets/994805260223102976/problems/1038429065476579328

题目描述:

知识点:数学

思路:按题述编程即可

注意点:

30倒转后是3。

时间复杂度是O(n),其中n为乘积的位数。空间复杂度是O(1)。

C++代码:

#include<iostream> #include<sstream> using namespace std; int main(){ int A, B; scanf("%d %d", &A, &B); stringstream ss; ss << (A * B); string result; ss >> result; int i = result.length() - 1; while(result[i] == '0'){ i--; } for(; i >= 0; i--){ cout << result[i]; } return 0; }

C++解题报告:

 

转载请注明原文地址: https://www.6miu.com/read-5029622.html

最新回复(0)