Caesar
要求实现用户输入一个数改变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的更多相关文章
- Codeforces118D Caesar's Legions(DP)
题目 Source http://codeforces.com/problemset/problem/118/D Description Gaius Julius Caesar, a famous g ...
- codeforces118D. Caesar's Legions
地址:http://www.codeforces.com/problemset/problem/118/D 题目: Gaius Julius Caesar, a famous general, lov ...
- 趣味题:恺撒Caesar密码(c++实现)
描述:Julius Caesar 生活在充满危险和阴谋的年代.为了生存,他首次发明了密码,用于军队的消息传递.假设你是Caesar 军团中的一名军官,需要把Caesar 发送的消息破译出来.并提供给你 ...
- Caesar's Legions(三维dp)
Caesar's Legions Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u S ...
- 1009: 恺撒Caesar密码
1009: 恺撒Caesar密码 时间限制: 10 Sec 内存限制: 128 MB提交: 349 解决: 215[提交][状态][讨论版] 题目描述 Julius Caesar 生活在充满危险和 ...
- 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 ...
- [WeChall] Training: Crypto - Caesar I (Crypto, Training)
Training: Crypto - Caesar I (Crypto, Training) Crypto - Caesar I As on most challenge sites, there a ...
- 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 ...
- 2018 ACM-ICPC 宁夏 C.Caesar Cipher(模拟)
In cryptography, a Caesar cipher, also known as the shift cipher, is one of the most straightforward ...
随机推荐
- JVM分代垃圾回收策略的基础概念
由于不同对象的生命周期不一样,因此在JVM的垃圾回收策略中有分代这一策略.本文介绍了分代策略的目标,如何分代,以及垃圾回收的触发因素. 文章总结了JVM垃圾回收策略为什么要分代,如何分代,以及垃圾回收 ...
- c++文件流
前言 文件流能够从文件系统中读取数据并向文件中写入数据. 文件输入流适用于读取配置数据.读取保存的文件以及批处理基于文件的数据等任务.Fprintf,fwrite,fputs 文件输出流适用于保存状态 ...
- 【Android - 框架】之Retrofit的使用
Retrofit是Square公司发布的一个可以应用在Android和Java中的Http客户端访问框架,其底层应用的是OkHttp. 在这个帖子中,我们以下面这个Http请求为例: https:// ...
- C++一些注意点之操作符重载
重载操作符需要注意 (1)重载操作符必须具有一个类类型操作数.不能重载内建类型的操作符. operator +(int,int);//这个是错误的,都为内建类型 operator +(int,clas ...
- Assigning retained object to unsafe property;object will be released after assignment
解决方法,将变量 @property (assign) UILabel *titleView; 改为 @property (retain) UILabel *titleView;
- hdu-5009-Paint Pearls-dp
由题意我们能够知道,花费最多为n. 所以单次最多涂掉sqrt(n)种颜色. dp[i]:涂到第i个位置.之前的花费最少为多少. biao[i][j]:在第i个位置,往前涂j-1种颜色,涂到哪个位置. ...
- ios-点击屏幕,隐藏键盘
ios-点击屏幕,隐藏键盘 - (void)getFirstRegist{ //结束键盘编辑 __weak typeof(self)weakSelf = self; UITapGestureRecog ...
- Lamp环境部署指南
1.安装apache 1)安装httpd: yum install httpd 2)启动httpd服务 service httpd start 2.安装mysql 1)安装mysql yum inst ...
- asp.net模态窗口返回值
个人感觉模态窗口在做网站的时候,使用到的比较少,前段时间在做项目时要实现以模态窗口传值和接收返回值, 模态窗口传值实现比较简单,但是做好后发现在Chrome浏览器中接收不到返回值,修改好Chrome浏 ...
- GoogleAuthenticator
<?php /** * PHP Class for handling Google Authenticator 2-factor authentication * * @author Micha ...