当前位置:网站首页>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;
}
边栏推荐
- pytorch 读写文件
- 不使用union实现Mysql 列转行
- Nuxt - set SEO related tags, page titles, icons, etc. separately for each page (page configuration head)
- On June 27, 2022, I have the right to choose the journey of the summer vacation.
- 赚钱的5个层次,你在哪一层?
- 二叉树序列化与反序列化(leetcode(困难))
- SQL two columns become multi row filter display
- How sqlserver queries and removes results with null fields in the whole column
- Ansible最佳实践之Playbook不同上下文提权Demo
- Mécanisme d'attention du canal de fixation
猜你喜欢

【C语言】解决 “address of stack memory associated with local variable ‘num‘ returned”

JSX的基本使用

sql两列变为多行过滤显示

科技云报道:混合办公的B面:安全与效率如何兼得?

技术:如何设计zkVM电路

The second meeting of the Second Council of Euler open source community was held, and Xinhua III, hyperfusion and Godson Zhongke became members of the Council

MySQL review materials (additional) case when

Whose encryption key is written in the code? (that's you)

Anaconda's own Spyder editor starts with an error

Seattention channel attention mechanism
随机推荐
What is the dry goods microservice architecture? What are the advantages and disadvantages?
Remote connection of raspberry pie in VNC Viewer Mode
Live broadcast preview | neurips special session I & Young Scientists special session
情绪的变化需要控制
CANoe-如何在Trace窗口解析报文并显示信息(Program Node和结构体类型系统变量的使用)
IDEA修改jvm内存
[new function] ambire wallet integrates Metis network
Data collection and management [13]
【新功能】Ambire 钱包集成了 Metis 网络
The virtual machine MySQL cannot be connected to the local computer
赚钱的5个层次,你在哪一层?
moudo网络库剖析
Idea modifying JVM memory
Runtimeerror in yolox: dataloader worker (PID (s) 17724, 1364, 18928) exited unexpectedly
Microsecond TCP timestamp
《运营之光3.0》全新上市——跨越时代,自我颠覆的诚意之作
Mécanisme d'attention du canal de fixation
Data collection and management [12]
Apifox : 不仅是Api调试工具,更是开发团队的协作神器
快速开发项目-VScode插件