密码学作业,维吉尼亚密码的代码实现

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int cnt1=0,cnt2=0;
    string s;
    string a,temp1,temp2;
    getline(cin,s);
    getline(cin,a);
    int c=a.size();
        for(int j=0;j<s.size();j++)
        {
            int temp=(int)s[j];
            if(temp>=64&&temp<=90)
            {
                temp+=(a[cnt1%c]-'A');
                while(temp>90)
                temp-=26;
                cnt1++;
            }
            else if(temp>=97&&temp<=122)
            {
                temp+=(a[cnt1%c]-'a');
                while(temp>122)
                temp-=26;
                cnt1++;
            }
            temp1+=(char)temp;
        }
        cout<<temp1<<endl;

    return 0;
}

感谢观看喵

posted @ 2025-05-12 18:15  magic_here_tonight  阅读(11)  评论(0)    收藏  举报