作者在 2010-05-10 08:23:29 发布以下内容
/*输入123,输出321*/
#include<stdio.h>
#define L sizeof(number)
typedef struct number
{
int num;
struct number *next;
}number;
number* integerlist(int d)
{
number *last,*p,*head;
int n;
n=d;
head=NULL;
do
{
p=(number*)malloc(L);
p->next=NULL;
if(head==NULL)
{
head=p;
last=p;
}
p->num=n%10;
last->next=p;
last=p;
n=n/10;
}while(n!=0);
return head;
}
int main()
{
int d;
number *p;
scanf("%d",&d);
p=integerlist(d);
while(p!=NULL)
{
printf("%d",p->num);
p=p->next;
}
printf("\n");
}