要求实现用户输入一个数改变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. C语言中数据类型转换的学习

    1. 整型和枚举类型数据的转换 测试代码如下: #include <stdio.h> typedef enum _E_TYPE_T {     E_TYPE_1 = -1,     E_T ...

  2. postgresql数据库的数据导出

    一.pg_dump的用法:数据库的导入导出是最常用的功能之一,每种数据库都提供有这方面的工具,例如Oracle的exp/imp,Informix的dbexp/dbimp,MySQL的mysqldump ...

  3. jersey构建rest服务返回json数据

    1.  eclipse 创建 dynamic web project 2.  将jersey相关jar包放到libs目录下 3. web.xml 增加 jersey 相关内容 <?xml ver ...

  4. 无法将类型“System.Collections.Generic.IEnumerable<EmailSystem.Model.TemplateInfo>”隐式转换为“System.Collections.Generic.List<EmailSystem.Model.TemplateInf

    List<Model.Template> templateList = templateBLL.RecommendTemplateByOrder(modelEbay); List<M ...

  5. ORACLE EXP命令

    本文对Oracle数据的导入导出 imp ,exp 两个命令进行了介绍, 并对其对应的參数进行了说明,然后通过一些演示样例进行演练,加深理解.文章最后对运用这两个命令可能出现的问题(如权限不够,不同o ...

  6. linux系统启动

    在本文中,我们按电源按钮简要叙述,以便能够登录到系统,在此期间,系统和计算机硬件是如何一起工作.既作为自己整理知识的摘要,有可能linux0绍,高手请略过. 一般来说linux的启动能够分成三个阶段: ...

  7. spin_lock &amp; mutex_lock的差别?

    本文由该问题引入到内核锁的讨论,归纳例如以下 为什么须要内核锁? 多核处理器下,会存在多个进程处于内核态的情况,而在内核态下,进程是能够訪问全部内核数据的,因此要对共享数据进行保护,即相互排斥处理 有 ...

  8. HTML表单介绍

    表单语法结构如下: <form action="url" method="get|post" name="value" enctype ...

  9. Android Activity横竖屏转换的生命周期

    新创建一个Activity,用来此次测试. 先贴代码 package com.hugo.apj.activitylifetest; import android.support.v7.app.AppC ...

  10. 关于mvc 分页的 这两个结合着用

    http://www.cnblogs.com/JackFeng/archive/2010/01/25/JackFeng.html http://www.webdiyer.com/mvcpager/de ...