当前位置:网站首页>P1079 Vigen è re password (simple analog & string)

P1079 Vigen è re password (simple analog & string)

2021-08-10 08:04:26 wx6110fa547fd20

P1079 Vigenère password ( Simple simulation & character string )

  Subject portal

The question : Give the key and ciphertext to find the plaintext .

Ideas : There are two situations : Each case can be divided into case and case . Case can be used toupper( ),tolower( ) Realization .ps: It looks fancy .

AC Code :

#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b,c;
	cin>>b>>c;
	int lb=b.size(),lc=c.size();
	for(int i=0;i<lc;i++){
		if(toupper(c[i])>=toupper(b[i%lb])){
			if(c[i]>='A')
			printf("%c",'A'+(c[i]-toupper(b[i%lb])));
			else printf("%c",'a'+(c[i]-tolower(b[i%lb])));
		}
		else {
			if(c[i]>='A')
			printf("%c",c[i]+('Z'-toupper(b[i%lb])+1));
			else printf("%c",c[i]+('z'-tolower(b[i%lb])+1));
		}
	}
	return 0;
}

      
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.

版权声明
本文为[wx6110fa547fd20]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/08/20210810080205561x.html

随机推荐