数据结构实验之栈一:进制转换
Time Limit: 1000MS
Memory Limit: 65536KB
Problem Description
输入一个十进制整数,将其转换成对应的R(2<=R<=9)进制数,并输出。
Input
第一行输入需要转换的十进制数;
第二行输入R。
第二行输入R。
Output
输出转换所得的R进制数。
Example Input
1279 8
Example Output
2377
#include<stdio.h> int a[110]; int fun(int n,int m) { int top=0; while(n) { a[top++]=n%m; n=n/m; } return top; } int main() { int n,m,i; scanf("%d%d",&n,&m); int k=fun(n,m); for(i=k-1;i>=0;i--) printf("%d",a[i]); printf("\n"); }