码迷,mamicode.com
首页 > 其他好文 > 详细

luoguP1079 Vigenère 密码 题解(NOIP2012)

时间:2018-04-21 16:13:24      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:clu   line   return   targe   name   noip   span   algorithm   tac   

P1079 Vigenère 密码 题目

#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<ctime>
#include<queue>
#include<stack>
#define rg register
#define lst long long
#define N 1050
using namespace std;

int lmy,lmw,now=-1;
char my[N],mw[N],ans[N];

inline int read()
{
    rg int s=0,m=1;rg char ch=getchar();
    while(ch!=-&&(ch<0||ch>9))ch=getchar();
    if(ch==-)m=-1,ch=getchar();
    while(ch>=0&&ch<=9)s=(s<<3)+(s<<1)+ch-0,ch=getchar();
    return s*m;
}

int main()
{
    cin>>my>>mw;
//    puts(my),puts(mw);
    lmy=strlen(my),lmw=strlen(mw);
//    cout<<lmy<<" "<<lmw<<endl;
    for(rg int i=0;i<lmy;++i)
        if(my[i]>=a&&my[i]<=z)my[i]-=32;
//    puts(my);    
    for(rg int i=0;i<lmw;++i)
    {
        now++;
        if(now==lmy)now=0;
        ans[i]=mw[i]-my[now]+A;
        if(ans[i]<a&&(mw[i]>=a&&mw[i]<=z))ans[i]=mw[i]-my[now]+A+26;
        if(ans[i]<A&&(mw[i]>=A&&mw[i]<=Z))ans[i]=mw[i]-my[now]+A+26;
    }
    puts(ans);
    return 0;
}

 

luoguP1079 Vigenère 密码 题解(NOIP2012)

标签:clu   line   return   targe   name   noip   span   algorithm   tac   

原文地址:https://www.cnblogs.com/cjoierljl/p/8901675.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!