当前位置:网站首页>1017 A除以B分
1017 A除以B分
2022-06-29 04:09:00 【乐乐~LL】
本题要求计算 A/B,其中 A 是不超过 1000 位的正整数,B 是 1 位正整数。你需要输出商数 Q 和余数 R,使得 A=B×Q+R 成立。
输入格式:
输入在一行中依次给出 A 和 B,中间以 1 空格分隔。
输出格式:
在一行中依次输出 Q 和 R,中间以 1 空格分隔。
输入样例:
123456789050987654321 7
输出样例:
17636684150141093474 3代码如下:
#include<stdio.h>
int main()
{
//越界
char a[10000] = { 0 };
int b,i,yu,j=0;
scanf("%s %d", a, &b);
for (i = 0; a[i] != '\0'; i++)
{
a[i] -= '0';
j++;
}
for (i = 0; i<j; i++)
{
if (i == 0 && (a[i]) / b == 0)
{
a[i + 1] = a[i] * 10 + a[i + 1];
if(j==1)
printf("0");
}
else
{
printf("%d", a[i] / b);
a[i + 1] = (a[i] % b) * 10 + a[i+1];
}
yu = (a[i]) % b;
}
printf(" %d\n", yu);
return 0;
}
边栏推荐
- [FPGA mathematical formula] use FPGA to realize common mathematical formulas
- [new function] ambire wallet integrates Metis network
- 我的创作纪念日
- How to keep database and cache consistent
- 《运营之光3.0》全新上市——跨越时代,自我颠覆的诚意之作
- 为什么说测试岗位是巨坑?8年测试人告诉你千万别上当
- 【FPGA数学公式】使用FPGA实现常用数学公式
- Data statistical analysis (SPSS) [5]
- Analysis of moudo Network Library
- 使用AssetStudio/UnityStudio UABE等
猜你喜欢

yolox出现 RuntimeError: DataLoader worker (pid(s) 17724, 1364, 18928) exited unexpectedly

Baidu AI Cloud service grid product CSM release 𞓜 hot public beta

HCIE-Security Day41:理论学习:信息收集与网络探测

技术:如何设计zkVM电路
![[new function] ambire wallet integrates Metis network](/img/29/8a8c0cd40c51cef1174ee59706d4c9.png)
[new function] ambire wallet integrates Metis network

Mécanisme d'attention du canal de fixation

选对学校,专科也能进华为~早知道就好了

赚钱的5个层次,你在哪一层?

【C语言】 详解线程退出函数 pthread_exit

Kingbase export table structure
随机推荐
On June 27, 2022, I have the right to choose the journey of the summer vacation.
中小型企业网络的组建
Mécanisme d'attention du canal de fixation
Remote connection of raspberry pie in VNC Viewer Mode
【C语言】解决 “address of stack memory associated with local variable ‘num‘ returned”
Pytorch read / write file
Data statistical analysis (SPSS) [5]
在命令行登录mysql数据库以及查看版本号
选对学校,专科也能进华为~早知道就好了
String differences between different creation methods
NotImplementedError: Could not run torchvision::nms
自己动手搭建一个简单的网站
Implementation of b+ tree index based on xlsx
Why are you a test / development programmer? Can you recall
Whose encryption key is written in the code? (that's you)
[FPGA mathematical formula] use FPGA to realize common mathematical formulas
CDC2.2.1还不支持postgresql14.1么?基于pgbouncer连接方式下,以5433
sink端 一般都是jdbc的insert update delete么?
使用AssetStudio/UnityStudio UABE等
MySQL复习资料(附加)case when