|
Rivojlantirish va
|
bet | 2/2 | Sana | 13.05.2024 | Hajmi | 186,77 Kb. | | #229958 |
Bog'liq 2.1-Амалий машғулот#include <iostream> #include tring.h> using namespace std; int main() {
char s1[50],s2[50];int k; cout<<"Shifrlash:"<ndl; 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<2[i];cout<<endl; cout<<"Deshifrlash:"<ndl;
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<<endl;
return 0;}
Dastur natijasi:
Topshiriq:
1. Har bir talaba Familiya ismini lotin alifbosi jadvalidan foydalanib shifrlaydi, deshifrlaydi va shunga mos dastur tuzadi. Talaba uchun jurnaldagi tartib raqami kalit (K) hisoblanadi.
|
| |