链栈

来源:互联网 发布:合金装备5连接网络 编辑:程序博客网 时间:2024/06/05 03:47
#include<iostream>using namespace std;typedef struct node{int data;struct node *next;} *stack;void init(stack &s){s=NULL;}int pop(stack &s){int x;x=s->data;s=s->next;return x;}void push(stack &s,int e){stack p;p=new node;p->data=e;p->next=s;s=p;}int main(){int i,n;stack s;init(s);while(cin>>n){  while(n)    { push(s,n%5); n/=5;}    while(s)      cout<<pop(s);    cout<<endl;}return 0;}


原创粉丝点击