进制之间的转换

来源:互联网 发布:阿里妈妈淘宝客优惠券 编辑:程序博客网 时间:2024/06/07 09:15
#include <stdio.h>#include <stdlib.h>int main(){    int x,y,cnt=0,w;    int n[100]={0};    scanf("%d%d",&x,&w);    while(x!=0)    {        n[cnt]=x%w;        cnt++;        x=x/w;    }    for(y=cnt-1;y>=0;y--)    {        printf("%d",n[y]);    }    printf("\n");    return 0;}

这里写图片描述

原创粉丝点击