解题思路:
注意事项:
参考代码:
#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 人评分
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:703 |
九宫重排 (C++代码)浏览:1410 |
人见人爱A+B (C语言代码)浏览:663 |
C语言训练-求PI* (C语言代码)浏览:637 |
C语言训练-数字母 (C语言代码)浏览:670 |
C语言训练-求1+2!+3!+...+N!的和 (C语言代码)浏览:821 |
WU-拆分位数 (C++代码)浏览:819 |
简单的a+b (C语言代码)浏览:560 |
DNA (C语言描述,蓝桥杯)浏览:1653 |
1011题解浏览:819 |