标签:就是 std -- end 取模运算 ras temp har nbsp
之前总结过,大数问题,取模就是取商取余数;
#include<iostream> #include<stdlib.h> #include<string> using namespace std; string devide(int& r, string s, int n) { string ss = ""; for (int i = 0; i < s.size(); i++) { int temp = r*10 + int(s[i] - ‘0‘); ss += char(‘0‘ + temp / n); r = temp % n; } while (ss.size() > 1 && ss[0] == ‘0‘) ss.erase(0, 1); return ss; } void mutipl(string &s, int n) { int r = 0; for (int i = s.size() - 1; i >= 0; i--) { int temp = r + int(s[i] - ‘0‘)*n; s[i] = char(temp % 10+‘0‘); r = temp / 10; } while (r != 0) { s = char(r % 10 + ‘0‘) + s; r /= 10; } } int main() { string s; while (cin >> s) { //cin >> s; mutipl(s, 225); cout << s << endl; } return 0; }
标签:就是 std -- end 取模运算 ras temp har nbsp
原文地址:https://www.cnblogs.com/songlinxuan/p/12687897.html