K=22, C= TKHEMGHKRW BWUKUW
A
|
B
|
C
|
D
|
E
|
F
|
G
|
H
|
I
|
J
|
K
|
L
|
M
|
N
|
O
|
P
|
Q
|
R
|
S
|
T
|
U
|
V
|
W
|
X
|
Y
|
Z
|
K
|
L
|
M
|
N
|
O
|
P
|
Q
|
R
|
S
|
T
|
U
|
V
|
W
|
X
|
Y
|
Z
|
A
|
B
|
C
|
D
|
E
|
F
|
G
|
H
|
I
|
J
|
Deshifrlash uchun ham shifrlashda ishlatilgan jadvaldan foydalanamiz, ya`ni jadvalni birinichi qatorini Lotin alfabiti harflarini tartibli ketma-ketligida to`ldiramiz, ikkinchi qatorni esa kalitimiz 10 ga teng bo`lganligi uchun, 10 ta harf qoldirib Lotin harflari ketma-ketligini yozamiz,bu yerda 2-qator K harfidan boshlanadi. Keyingi qiladigan ishimiz 2-qatordan shifrmatndagi harflarni topamiz va 1-qatorda turgan mos harfga almashtiramiz: Masalan, shifrmatndagi G harfini 2-qatordan topamiz va G harfi tepasidagi W harfi ekanligiga guvoh bo`lamiz, 2-qatordagi J harfi, 1-qatordan Z harfiga to`g`ri keladi va shu yo`sinda davom etamiz.
Deshifrlangan matn tayyor: T0= XOLIQULOVA FAYOZA
Dastur kodi:
#include
#include
using namespace std;
int main()
{ char s1[50],s2[50];int k;
cout<<"Shifrlash:"<cout<<"Satrni kiriting:";
cin.getline(s1,sizeof(s1));
cout<<"Kalitni kiriting:K=";cin>>k;
for(int i=0;s1[i]!='\0';i++){
if((int)s1[i]>=65 and (int)s1[i]<=90){
if((int)s1[i]+k>90)s2[i]=(int)s1[i]+k-26;
else s2[i]=(int)s1[i]+k;}
else if((int)s1[i]>=97 and (int)s1[i]<=122){
if((int)s1[i]+k>122)s2[i]=(int)s1[i]+k-26;
else s2[i]=(int)s1[i]+k;}}
for(int i=0;i<=strlen(s2)-1;i++)
cout<for(int i=0;s2[i]!='\0';i++){
if((int)s2[i]>=65 and (int)s2[i]<=90){
if((int)s2[i]-k<65)s1[i]=(int)s2[i]-k+26;
else s1[i]=(int)s2[i]-k;}
else if((int)s2[i]>=97 and (int)s2[i]<=122){
if((int)s2[i]-k<97)s1[i]=(int)s2[i]-k+26;
else s1[i]=(int)s2[i]-k;}}
cout<return 0;}
Dastur natijasi:
Dostları ilə paylaş: |