J.H


私信TA

用户名:dotcpp0649969

访问量:3399

签 名:

等  级
排  名 78
经  验 9396
参赛次数 1
文章发表 135
年  龄 0
在职情况 学生
学  校 桂林理工大学
专  业 计算机科学与技术

  自我简介:

TA的其他文章

解题思路:

注意事项:

参考代码:

#include<stdio.h>

#include<stdlib.h>

typedef struct linkednode

{

    int data;

    struct linkednode* next;

}Linkedstack;

Linkedstack* init_linkedstack()

{

    Linkedstack* top;

    top = (Linkedstack*)malloc(sizeof(Linkedstack));

    if (top != NULL)

        top->next = NULL;

    return top;

}

int Push_linkedstack(Linkedstack* top,int x)

{

    Linkedstack* node = (Linkedstack*)malloc(sizeof(Linkedstack));

    if (node == NULL)

        return 0;

    else

    {

        node->data = x;

        node->next = top->next;

        top->next = node;

        return 1;

    }

}

void conversion(Linkedstack* top, int n)

{

    while (n > 0)

    {

        Push_linkedstack(top, n % 8);

        n /= 8;

    }

    Linkedstack* node = top->next;

    while (node != NULL)

    {

        printf("%d", node->data);

        node = node->next;

    }

    printf("\n");

}

int main()

{

    int n;

    while (scanf("%d", &n) != EOF)

    {

        Linkedstack* top = init_linkedstack();

        conversion(top, n);

        Linkedstack* temp = top->next,*node;

        while (temp != NULL)

        {

            node = temp->next;

            free(temp);

            temp = node;

        }

        free(top);

    }

    return 0;

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区