首页 > 其他 > 详细

大数取模

时间:2015-01-22 01:48:15      阅读:342      评论:0      收藏:0      [点我收藏+]
//大数取模
#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;
}

大数取模

原文:http://blog.csdn.net/liujan511536/article/details/42993099

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!