Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

.

: 3 2

1765 /


, 2010



.
2 .
:
.
2 .
Y,Z, ,B .
.
, ,
. 9 0, 0 9.
2 .
.

string,
. string- .
.
if
string
string.
.
.
if.
.

.
.
.

#include <cstdlib>
#include <iostream>
using namespace std;

string kodiranje(string tekst)


for(int i = 0; i < tekst.length(); i++)
2|

if((tekst[i]>='Y' && tekst[i]<='Z') || (tekst[i]>='y' && tekst[i]<='z'))


{

naredba

replace(tekst.begin(), tekst.end(), 'Y', 'B');// nova, no ednostavna

replace(tekst.begin(), tekst.end(), 'Z', 'A');


replace(tekst.begin(), tekst.end(), 'y', 'b');
replace(tekst.begin(), tekst.end(), 'z', 'a');
}
else{
if((tekst[i]>='A' && tekst[i]<='X') || (tekst[i]>='a' && tekst[i]<='x') )
{
if(i%2==0)//zameni za parni ili neparni
{
tekst[i]=tekst[i]+3;// 2 mesta posle bukvata e bukvata koja e na tretoto
mesto desno od nea ( zgolemi ja vrednosta 3 za da se promenat mestata )
}
}
else
{
if(tekst[i] >= '0' && tekst[i]<='9')
{
if(tekst[i] == '0')// zamena na brojkite oddelno
{
tekst[i] = '9';
}
else
{
if(tekst[i] == '1')
{
tekst[i] ='2';
}
else{
if(tekst[i] == '2')
{
tekst[i] = '1';
}
else{
if(tekst[i] == '3')
{
tekst[i] = '4';
}
else
{
if(tekst[i] == '4')
3|

{
tekst[i] ='3';
}
else
{
if(tekst[i] == '5')
{
tekst[i] = '6';
}
else
{
if(tekst[i] == '6')
{
tekst[i] = '5';
}
else
{
if(tekst[i] == '7')
{
tekst[i] ='8';
}
else
{
if(tekst[i] == '8')
{
tekst[i] = '7';
}
else
{
if(tekst[i] == '9')
{
tekst[i] = '0';
}
}}}}}}}}}}}

}
}
return tekst;

string dekodiranje(string tekst)// slicno na kodiranjeto no so zamena vo nekoi


"+" so "-" itn.
{
for(int i = 0; i < tekst.length(); i++)
{
if((tekst[i]>='A' && tekst[i]<='B') || (tekst[i]>='a' && tekst[i]<='b') )
{
4|

replace(tekst.begin(), tekst.end(), 'Y', 'B');


replace(tekst.begin(), tekst.end(), 'Z', 'A');
replace(tekst.begin(), tekst.end(), 'y', 'b');
replace(tekst.begin(), tekst.end(), 'z', 'a');
}
else
{
if((tekst[i]>='A' && tekst[i]<='X') || (tekst[i]>='a' && tekst[i]<='x') )
{
if(i%2==0)
{
tekst[i]=(char)((int)tekst[i]-3);
}
}
else
{
if(tekst[i] >= '0' && tekst[i]<='9')
{
if(tekst[i] == '9')
{
tekst[i] = '0';
}
else
{
if(tekst[i] == '2')
{
tekst[i] ='1';
}
else{
if(tekst[i] == '1')
{
tekst[i] = '2';
}
else{
if(tekst[i] == '4')
{
tekst[i] = '3';
}
else
{
if(tekst[i] == '3')
{
tekst[i] ='4';
}
else
{
5|

if(tekst[i] == '6')
{
tekst[i] = '5';
}
else
{
if(tekst[i] == '5')
{
tekst[i] = '6';
}
else
{
if(tekst[i] == '8')
{
tekst[i] ='7';
}
else
{
if(tekst[i] == '7')
{
tekst[i] = '8';
}
else
{
if(tekst[i] == '0')
{
tekst[i] = '9';
}
}}}}}}}}}}}
}

}
return tekst;

int main(int argc, char *argv[])


{
string tekst;
int n;
cout<<"Vnesete tekst koj zavrsuva
so '.' i sakate da se kodira ili
dekodira:";//meni
cout<<"\n";
getline(cin,tekst,'.');
cout<<"Vnesete 1 za vneseniot tekst da se kodira ili 2 za tekstot da se
dekodira:";
cout<<"\n";
6|

cin>>n;
if(n==1)
{
cout<<"Vie izbravte tekstot da se kodira:";
cout<<"\n";
cout<<kodiranje(tekst);
cout<<".";
}
else
{
if(n==2)
{
cout<<"Vie izbravte tekstot da se dekodira:";
cout<<"\n";
cout<<dekodiranje(tekst);
cout<<".";
}
else
{

cout<<"Toa meni ne postoi!";


cout<<"\n";
}
}
cout<<"\n";
system("PAUSE");
return EXIT_SUCCESS;


cstdlib iostream.
,
.

. for
string-

. if ili
replace(od pocetok , do krajot , a se zamenuva so , b ,). replace
if
. if 0 9
(if(tekst[i] >= '0' && tekst[i]<='9')),
2
ASCII ( if(i%2==0) {
tekst[i]=tekst[i]+3; ) a x A do X . replace
y z a b Y Z A B.
7|

,
replace a b y z A B Y Z.
if ,
if 3 -3
a x A do X.
if
1 2
.


:
Marjan Tanevski so broj na index 1765 e roden vo Bitola 09 08 1991.

:
Paujdn Tdnhvvkl vo buom qa iqdhx 2856 h uogeq Eiwooa 90 97 2002.

Paujdn Tdnhvvkl vo buom qa iqdhx 2856 h uogeq


Eiwooa 90 97 2002 : Marjan Tanevski so broj na index 1765 e roden vo
Bitola 09 08 1991.
8|

9|

You might also like