当前位置:网站首页>C-10 program error correction (recursive function): number to character
C-10 program error correction (recursive function): number to character
2022-04-23 03:20:00 【Tang Encheng_ hhhc】
Problem C: Program error correction ( Recursive function ): Number to character
Time Limit: 1 Sec Memory Limit: 64 MB
Submit: 4724 Solved: 3139
Description
In the following program “/ ***** N ***** /” There is an error in the next line of , Please correct ( Be careful : No extra bank is allowed 、 Line reduction 、 Add sentence 、 Subtract , Otherwise, we will be responsible for the consequences ). The program function : Use recursion to convert a six digit integer n Convert to string , For example, the input 123456, Expected output string "123456". #include void itoa(long i,char s) { if(i==0) return; /***** 1 */ s = ‘1’+i%10; itoa(i/10,s-1); } void main() { long n; char str[7]=""; scanf("%ld",&n); / 2 ******/ itoa(n,str+6); printf("%s",str); }
Input
Enter a six digit positive integer n.
Output
Convert the integer to the corresponding string .
Sample Input`
123456
Sample Output
123456
#include <stdio.h>
void itoa(long i,char *s);
int main()
{
long n;
scanf("%ld",&n);
char s[7] = " ";
itoa(n,s+5);
printf("%s\n",s);
return 0;
}
void itoa(long i,char *s)
{
if (i == 0)
return;
else
{
*s = '0' + i%10;
itoa(i/10,s-1);
}
}
That's interesting , There are many mistakes
版权声明
本文为[Tang Encheng_ hhhc]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220621320232.html
边栏推荐
- Top ten project management software similar to JIRA
- Improvement of ref and struct in C 11
- Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]
- 2022G2电站锅炉司炉考试题库及在线模拟考试
- 软件测试相关知识~
- xutils3修改了我提报的一个bug,开心
- 2022山东省安全员C证上岗证题库及在线模拟考试
- Peut recevoir plusieurs paramètres de type de données - paramètres variables
- js 中,为一个里面带有input 的label 绑定事件后在父元素绑定单机事件,事件执行两次,求解
- Is it difficult to choose binary version control tools? After reading this article, you will find the answer
猜你喜欢
【VS Code】解决jupyter文件在vs code中显示异常的问题
《C语言程序设计》(谭浩强第五版) 第8章 善于利用指针 习题解析与答案
OLED多级菜单记录
TCP three handshakes and four waves
[Mysql] LEFT函數 | RIGHT函數
12. < tag linked list and common test site synthesis > - lt.234 palindrome linked list
Drawing polygons with < polygon / > circular array in SVG tag
Experiment 6 input / output stream
移植tslib时ts_setup: No such file or directory、ts_open: No such file or director
一套组合拳,打造一款 IDEA 护眼方案
随机推荐
C language to achieve address book - (static version)
Experiment 6 input / output stream
. net webapi access authorization mechanism and process design (header token + redis)
2022a special equipment related management (elevator) work license question bank and simulation examination
全新的ORM框架——BeetlSQL介绍
幂等性实践操作,基于业务讲解幂等性
General testing technology [1] classification of testing
Batch download of files ---- compressed and then downloaded
通过 zxing 生成二维码
12.<tag-链表和常考点综合>-lt.234-回文链表
A comprehensive understanding of static code analysis
数据库表中不建索引,在插入数据时,通过sql语句防止重复添加(转载)
Mysql database design specification
MySql分组查询规则
How to achieve centralized management, flexible and efficient CI / CD online seminar highlights sharing
poi根据数据创建导出excel
数据挖掘系列(3)_Excel的数据挖掘插件_估计分析
Advanced sorting - fast sorting
MySQL query specifies that a row is sorted to the first row
ThreadLocal test multithreaded variable instance