#include <stdio.h> int itob(int n,int b) { int m = 0; int i = 0; do { m = n % b; n = n / b; s[i] = m; i++; } while (n); for (i = i - 1; i >= 0;i--) { printf("%d", s[i]); } printf("\n"); } int main() { int n = 0; int b = 0; printf("请输入你想转换的数:\n"); scanf("%d", &n); printf("请输入你想转换的进制:\n"); scanf("%d", &b); printf("转换后为:\n"); itob(n,b); return 0; }
时间: 2024-11-03 18:30:08