c 加密数字
#include<stdio.h>
#include<stdlib.h>
//#define OK 1
//#define ERROR 0
typedef char ElemType;
//typedef int status;
// 创建结构体
typedef struct node
{
ElemType data;
struct node *prior;
struct node *next;
}Node,*List;
//建立空表 并建表
int InitList(List *L)
{
Node *p,*q;
int i ;
*L=(List)malloc(sizeof(Node));
if(!(*L))
{
return 0;
}
(*L)->next=(*L)->prior=NULL;
p=(*L);
for(i=0;i<26;i++)
{
q=(Node *)malloc(sizeof(Node));
if(!q)
{
return 0;
}
q->data='A'+i;
q->prior=p;
q->next=p->next;
p->next=q;
p=q;
}
p->next=(*L)->next;
(*L)->next->prior=p;
return 1;
}
void paixu(List *L,int i)
{
Node *p=(*L)->next;
if(i>0)
{
do
{
(*L)=(*L)->next;
}while(--i);
}
if(i<0)
{
while(i==0)
{
p=p->prior;
++i
}
(*L)=p;
}
}
int main()
{
List L;
int i ;
InitList(&L);
printf("请输入一个整数:");
scanf("%d",&i);
printf("\n");
paixu(&L,i);
for(i=0;i<26;i++)
{
L=L->next;
printf("%c",L->data);
}
return 0;
}
