PX-33-进制输出

进制转换的函数    _itoa()

 

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>

void main()
{
    int num = 0;
    scanf("%d", &num);
    printf("num=%i", num);     //%d,%i一样的效果
    char str[32] = {0};
    _itoa(num, str, 2);    //字符串,第一个整数,str字符串,2
    printf("\n%s", str);

    _itoa(num, str, 8);
    printf("\n%s", str);

    _itoa(num, str, 10);
    printf("\n%s", str);

    _itoa(num, str, 16);
    printf("\n%s", str);
    system("pause");
}

// < 1.txt 用1.txt来输入
//>2.txt用2.txt输出

 

posted @ 2016-12-15 11:57  silvercell  阅读(900)  评论(0)    收藏  举报