2022级统计计算机双学位《程序设计原理与C语言》上机作业

1036. itob

单点时限: 2.0 sec

内存限制: 512 MB

Write a function itob(n,s,b) that converts the integer n into a base b character representation in the string s . In particular, itob(n,s,16) formats s as a hexadecimal integer in s.

Write a program to call the function.

/***************************************************************/
/*                                                             */
/*  DON'T MODIFY main function ANYWAY!                         */
/*                                                             */
/***************************************************************/


#include <stdio.h>

void itob(int n,char s[100],int b)
{
    // TODO: your function definition

}

int main()
{
    int n,b;
    char s[100];
    scanf("%d%d",&n,&b);
    itob(n,s,b);
    printf("%s\n",s);
    return 0;
}

输入格式

Input n, b. (2b36)

输出格式

Ouput the string s .

样例

Input
-489968884 18
Output
-E757FBA
Input
900479765 35
Output
H52FIA
Input
7 2
Output
111
Input
-4 3
Output
-11