当前位置:网站首页>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
边栏推荐
- JS recursive tree structure calculates the number of leaf nodes of each node and outputs it
- Top ten project management software similar to JIRA
- 月薪10k-20k都无法回答的事务问题,你会吗?
- Experiment 6 input / output stream
- MySQL port is occupied when building xampp
- Super easy to use [general excel import function]
- C language to achieve address book - (static version)
- OLED multi-level menu record
- Experiment 5 components and event handling
- Flink实时数仓项目—DWS层设计与实现
猜你喜欢

LoadRunner - performance testing tool

2022 P cylinder filling training test questions and simulation test

Web Course Design - his system

Log4net is in Net core usage

Fight leetcode again (290. Word law)

Build websocket server in. Net5 webapi

一套组合拳,打造一款 IDEA 护眼方案
![Use of ADB command [1]](/img/e6/fb8fd6956c226f75b831f8eb46277f.png)
Use of ADB command [1]

“如何实现集中管理、灵活高效的CI/CD”在线研讨会精彩内容分享

2022年度Top9的任务管理系统
随机推荐
poi根据数据创建导出excel
Fundamentals of software testing and development
2022 P cylinder filling training test questions and simulation test
Fight leetcode again (290. Word law)
Eight elder brothers chronicle [4]
通过 zxing 生成二维码
Test experience data
Huawei mobile ADB devices connection device is empty
ASP. Net 6 middleware series - conditional Middleware
JSON related
The website JS in. Net core cefsharp chromium WebBrowser calls the C method in winfrom program
队列的存储和循环队列
Chapter 7 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of modular programming exercises with functions
The most understandable life cycle of dependency injection
js 中,为一个里面带有input 的label 绑定事件后在父元素绑定单机事件,事件执行两次,求解
MySQL query specifies that a row is sorted to the first row
Improvement of ref and struct in C 11
Peut recevoir plusieurs paramètres de type de données - paramètres variables
2022T电梯修理考试模拟100题及在线模拟考试
PID debugging of coding motor (speed loop | position loop | follow)