3172. 整数转换为字符串

单点时限: 2.0 sec

内存限制: 256 MB

使用 递归方法 定义函数 i2a,将 1 个非负整数转换成字符串。

//* Specification of i2a *

void i2a(char s[],long long int n);

/* PreCondition:

n is a non-negative integer, s is a character buffer

PostCondition:

put string representation of n in s

*/

Note: 如果 s 中存放一个字符串 “1234”,则 s+1 对应 “234”, s+2 对应 “34”…

只需按要求写出函数定义,并使用给定的测试程序测试你所定义函数的正确性。

不要改动测试程序。

测试正确后,将测试程序和函数定义一起提交到考试系统。

/*********/

/ /

/ DON'T MODIFY main function ANYWAY! /

/ /

/*********/

include

//* Specification of i2a *

void i2a(char s[],long long int n)

/* PreCondition:

n is a non-negative integer, s is a character buffer

PostCondition:

put string representation of n in s

*/

{ //TODO: your function definition – RECURSIVE SOLUTION

}

/*********/

int main()

{ long long int n;

char s[20];

scanf(“%I64d”,&n);

//* i2a is called here *****

i2a(s,n);

//********

printf(“%s\n”,s);

return 0;

}

输入格式

-

输出格式

-

样例

Input
-
Output
-

150 人解决,226 人已尝试。

199 份提交通过,共有 847 份提交。

3.7 EMB 奖励。

创建: 8 年,4 月前.

修改: 6 年,8 月前.

最后提交: 1 月,2 周前.

来源: N/A

题目标签