PAT乙级 1017. A除以B
2018-03-31 13:48
302 查看
1017. A除以B (20)
本题要求计算A/B,其中A是不超过1000位的正整数,B是1位正整数。你需要输出商数Q和余数R,使得A = B * Q + R成立。输入格式:
输入在1行中依次给出A和B,中间以1空格分隔。
输出格式:
在1行中依次输出Q和R,中间以1空格分隔。
输入样例:
123456789050987654321 7输出样例:
17636684150141093474 3
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main(){
char a[2000];
scanf("%s",a);
int b;
scanf("%d",&b);
int n = strlen(a);
int temp=0;
int flag = 0;
for(int i=0;i<n;i++){
temp = (a[i]-'0')+temp*10;
if(temp>=b){
printf("%d",temp/b);
flag = 1;
}
else if(flag){
printf("0");
}
temp = temp%b;
}
if(flag==0)
printf("0");
printf(" %d",temp);
}
相关文章推荐
- PAT乙级 1017. A除以B (20)
- pat 乙级 1017. A除以B (20)
- PAT-乙级-1017. A除以B (20)
- PAT_乙级 1017 A除以B
- PAT乙级1017. A除以B (20)
- PAT乙级 1017. A除以B (20)
- PAT 乙级 1017.A除以B(20)
- PAT乙级1017. A除以B 大数除以小数
- 乙级 PAT 1017. A除以B (20)
- PAT乙级.1017. A除以B (20)
- 1017. A除以B (20)--PAT乙级
- PAT(乙级)1017. A除以B
- PAT-乙级-1017. A除以B (20)
- PAT 乙级练习题1017. A除以B (20)
- 【PAT】(乙级)1017. A除以B (20)
- PAT乙级1017. A除以B (20)
- PAT 乙级 1017 A除以B (20)
- 浙江大学PAT乙级试题.1017. A除以B (20)C语言
- PAT乙级 1017. A除以B
- PAT乙级:1017. A除以B (C)