//大数取模 #include "cmath" #include "iostream" #include "string.h" using namespace std; int mod(char str[],int num) { int number[100]; for(int i=0;i<strlen(str);i++) number[i]=str[i]-'0'; int remainder=0; for(int i=0;i<strlen(str);i++) { remainder=((long long)remainder*10+number[i])%num; } return remainder; } int main(){ char ch[10] = {'1','3','\0'}; cout << mod(ch, 5); return 0; }
时间: 2024-11-02 23:20:52