1175:除以13
时间限制: 1000 ms 内存限制: 65536 KB
提交数: 9530 通过数: 5897
【题目描述】
输入一个大于0的大整数N,长度不超过100位,要求输出其除以13得到的商和余数。
【输入】
一个大于0的大整数,长度不超过100位。
【输出】
两行,分别为整数除法得到的商和余数。
【输入样例】
2132104848488485
【输出样例】
164008065268345
0
【参考代码】
#include <stdio.h>
#include <string.h>
#define N 110
char s[N];
int t[N];
int quo[N]; //商
int main()
{
int i,len,mod=0;//余数
gets(s);
len=strlen(s);
for(i=0;i<len;i++) //字符串转整型
{
t[i]=s[i]-'0';
}
for(i=0;i<len;i++)
{
t[i]=(mod*10)+t[i]; //被除数
quo[i]=t[i]/13; //存商
mod=t[i]%13; //存余数
}
i=0;
while(quo[i]==0 && len>1) //处理前置 0
{
i++;
}
while(i<len)
{
printf("%d",quo[i]);
i++;
}
printf("\n%d\n",mod);
return 0;
}
http://ybt.ssoier.cn:8088/problem_show.php?pid=1175