文章
34
粉丝
109
获赞
84
访问
37.3k
 
#include <stdio.h>
#include <string.h>
char s[6];
void reverse(char s[]) //翻转字符数组
{
    for (int i = 0; i < strlen(s) / 2; i++)
    {
        char temp = s[i];
        s[i] = s[strlen(s) - i - 1];
        s[strlen(s) - i - 1] = temp;
    }
}
char *toTow(int x)
{
    char s1[6] = {'0', '0', '0', '0', '0', '0'};
    int index = 0;
    while (x > 0)
    {
        s1[index++] = x % 2 + '0';
        x = x / 2;
    }
    strcpy(s, s1);
    reverse(s);
    // printf("%s\n", s);
    return s;
}
int main()
{
    for (int i = 0; i < 64; i++)
    {
        char *s = toTow(i);
        printf("%s\n", s);
    }
    return 0;
}
登录后发布评论
暂无评论,来抢沙发