大数_高精度除法
2014-01-02 21:18
197 查看
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
char *str;
int temp;
int N;
int i;
scanf("%d", &N);
while(N--){
str = (char*)malloc(sizeof(char) * 1000000);
scanf("%s", str);
temp = 0;
for(i = 0; str[i] != 0; i++){
temp = str[i] - '0' + temp * 10;
while(temp >= 9){
temp = temp % 9;
}
}
printf("%d\n", temp);
free(str);
}
return 0;
}
#include<string.h>
#include<stdlib.h>
int main()
{
char *str;
int temp;
int N;
int i;
scanf("%d", &N);
while(N--){
str = (char*)malloc(sizeof(char) * 1000000);
scanf("%s", str);
temp = 0;
for(i = 0; str[i] != 0; i++){
temp = str[i] - '0' + temp * 10;
while(temp >= 9){
temp = temp % 9;
}
}
printf("%d\n", temp);
free(str);
}
return 0;
}
相关文章推荐
- 高精度除法
- poj 2325 Persistent Numbers(高精度除法+贪心)
- [ACM模板] BigInt高精度加/减/除法
- 高精度正整数除法 大整数除法
- 卡特兰数,值得纪念下,包括了高精度乘法和除法。
- 高精度之大数除法
- 3118 高精度练习之除法
- 【MIPS编程】高精度整数除法
- poj 2325 Persistent Numbers(高精度除法+贪心)
- (高精度运算4.7.27)UVA 10494 If We Were a Child Again(大数除法&&大数取余)
- C语言 高精度除法
- 高精度除法(高精除高精)
- 7、大数,高精度计算---大数除法
- 使用java求高精度除法,要求保留N位小数
- 数论专题---除法表达式之高精度运算,扩展欧几里得算法
- 高精度除法
- 中石油-高精度除法-java版
- 高精度除法并计算除余数(综合高精减法和加法)
- 高精度之高精度除法(高精除以低精)
- poj 2325 Persistent Numbers(高精度除法+贪心)