要求实现用户输入一个数改变26个字母的排列顺序

例如输入3:

DEFGHIJKLMNOPQRSTUVWXYZABC

输入-3:

XYZABCDEFGHIJKLMNOPQRSTUVW

使用循环链表

代码如下:

 #include<stdio.h>
#include<stdlib.h> #define OK 1
#define ERROR 0 typedef int status;
typedef char ElemType; typedef struct DualNode
{
ElemType data;
struct DualNode *prior;
struct DualNode *next;
}DualNode,*DuLinkList; status InitList(DuLinkList *L)
{
DualNode *p,*q;
int i;
*L=(DuLinkList)malloc(sizeof(DualNode)); if(!(*L))
return ERROR; (*L)->next=(*L)->prior=NULL;
p=(*L); for(i=;i<;i++)
{
q=(DualNode*)malloc(sizeof(DualNode));
if(!q)
return ERROR; 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 OK;
} void Caesar(DuLinkList *L,int i)
{
if(i>)
{
do
{
(*L)=(*L)->next;
}while(--i);
}
if(i<)
{
(*L)=(*L)->next;
do
{
(*L)=(*L)->prior;
}while(i++);
}
} int main()
{
DuLinkList L;
int i,n;
printf("请输入一个整数:");
scanf("%d",&n); InitList(&L);
Caesar(&L,n); for(i=;i<;i++)
{
L=L->next;
printf("%c",L->data);
}
printf("\n"); return ; }

Caesar的更多相关文章

  1. Codeforces118D Caesar's Legions(DP)

    题目 Source http://codeforces.com/problemset/problem/118/D Description Gaius Julius Caesar, a famous g ...

  2. codeforces118D. Caesar's Legions

    地址:http://www.codeforces.com/problemset/problem/118/D 题目: Gaius Julius Caesar, a famous general, lov ...

  3. 趣味题:恺撒Caesar密码(c++实现)

    描述:Julius Caesar 生活在充满危险和阴谋的年代.为了生存,他首次发明了密码,用于军队的消息传递.假设你是Caesar 军团中的一名军官,需要把Caesar 发送的消息破译出来.并提供给你 ...

  4. Caesar's Legions(三维dp)

    Caesar's Legions Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u S ...

  5. 1009: 恺撒Caesar密码

    1009: 恺撒Caesar密码 时间限制: 10 Sec  内存限制: 128 MB提交: 349  解决: 215[提交][状态][讨论版] 题目描述 Julius Caesar 生活在充满危险和 ...

  6. We Chall-Training: Crypto - Caesar I-Writeup

    MarkdownPad Document html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,ab ...

  7. [WeChall] Training: Crypto - Caesar I (Crypto, Training)

    Training: Crypto - Caesar I (Crypto, Training) Crypto - Caesar I As on most challenge sites, there a ...

  8. WeChall_Training: Crypto - Caesar I (Crypto, Training)

    As on most challenge sites, there are some beginner cryptos, and often you get started with the good ...

  9. 2018 ACM-ICPC 宁夏 C.Caesar Cipher(模拟)

    In cryptography, a Caesar cipher, also known as the shift cipher, is one of the most straightforward ...

随机推荐

  1. select、poll、epoll三组IO复用

    int select(int nfds,fd_set* readfds,fd_set* writefds,fd_set* exceptfds,struct timeval* timeout)//其中n ...

  2. ng-repeat 遍历同值数组导致的报错

    http://blog.csdn.net/tyust512/article/details/50370624

  3. SDUTRescue The Princess(数学问题)

    题目描述 Several days ago, a beast caught a beautiful princess and the princess was put in prison. To re ...

  4. 【机房重构】SQL之视图

    近期在重构机房收费系统,越往后就会越感觉到这里很多其它的是对之前学过知识(数据库,设计模式)的一种应用和回想.比方在登录功能中用到了抽象加反射,在学生下机中,我们能够用触发器来同一时候更新两个表.这里 ...

  5. GNU GRUB version 0.97 (630K lower /2053824K upper memory)

    昨天把老板的IBM X61笔记本拿过来多系统,结果本以为很容易,直接ghost,结果悲剧发生啦,开机之后提示GNU GRUB version 0.97 (630K lower /2053824K up ...

  6. [转] 使用git自动部署简单网站

    要做什么 假设你有一个博客,有一台网站服务器(或者很多台作负载均衡的服务器),当你的博客要升级时,你可能要在你自己的电脑上写好代码(可能包括本地调试好),然后提交到git(或svn),然后在每个服务器 ...

  7. 本地如何搭建IPv6环境测试你的APP

    IPv6的简介 IPv4 和 IPv6的区别就是 IP 地址前者是 .(dot)分割,后者是以 :(冒号)分割的(更多详细信息自行搜索). PS:在使用 IPv6 的热点时候,记得手机开 飞行模式 哦 ...

  8. Linux 关闭及重启方式

    一.shutdown 命令 作用:关闭或重启系统 使用权限:超级管理员使用 常用选项 1. -r 关机后立即重启 2. -h关机后不重启 3. -f快速关机,重启时跳过fsck(file system ...

  9. Codeforces 552E - Vanya and Brackets【表达式求值】

    给一个只有加号和乘号的表达式,要求添加一对括号使得最后结果最大.表达式长度5000,乘号最多12个,表达式中数字只有1位. 左括号一定在乘号右边,右括号一定在乘号左边,因为如果不是这样的话,一定可以调 ...

  10. Castle Windsor Fluent Registration API

    一对一注册 直接注册组件 container.Register( Component.For<MyServiceImpl>() ); 注册接口并提供组件 container.Registe ...