#include <iostream>
#include <stdlib.h>
#include <string.h>
using namespace std;
class ciphere_Text
{
private:
struct base_Josephus
{
int x_J;
base_Josephus *next_Base;
base_Josephus(int temp_Jos,base_Josephus *t_J)
{
x_J=temp_Jos;
next_Base=t_J;
}
};
int result_Josephus(char x,int y)
{
int i,j,k;
int p1,p2;
p1=int_Value(x);p2=y;
typedef base_Josephus *main_Jos;
main_Jos temp_Main1=new base_Josephus(1,0);
temp_Main1->next_Base=temp_Main1;
main_Jos temp_Main2=temp_Main1;
for(i=2;i<=p1;i++)
temp_Main2=(temp_Main2->next_Base=new base_Josephus(i,temp_Main2));
while(temp_Main2!=temp_Main2->next_Base)
{
for(j=1;j<p2;j++)
temp_Main2=temp_Main2->next_Base;
temp_Main2->next_Base=temp_Main2->next_Base->next_Base;
}
k=temp_Main2->x_J;
return k;
}
char *c_Text;
int size_Text;
int int_Value(char x)
{
int i,j;
char a;
char m_Text[26],p_Text[26];
j=0;
for(i=0,a='a';a<'z';a++,i++)
m_Text[i]=a;
for(i=0,a='A';a<'Z';a++,i++)
p_Text[i]=a;
for(i=0;i<26;i++)
{
if(m_Text[i] || p_Text[i]==x)
j=i+1;
}
return j;
}
bool M_or_P()
{
int a;
a=rand()%10+1;
if(a%2==0)
return true;
else
return false;
}
char char_Value(int x)
{
int i;
bool k;
char a,j;
char m_Text[26],p_Text[26];
j=0;
for(i=0,a='a';a<'z';a++,i++)
m_Text[i]=a;
for(i=0,a='A';a<'Z';a++,i++)
p_Text[i]=a;
k=M_or_P();
if(k)
{
j=m_Text[x];
}
else
{
j=p_Text[x];
}
return j;
}
public:
ciphere_Text(char *date)
{
int i,random_Value;
size_Text=strlen(date);
int *temp_Array=new int[size_Text];
c_Text=new char[size_Text];
random_Value=1+rand()%25;
for(i=0;i<size_Text;i++)
{
temp_Array[i]=result_Josephus(date[i],random_Value);
}
for(i=0;i<size_Text;i++)
{
c_Text[i]=char_Value(temp_Array[i]);
}
}
char *give_Result()
{
return c_Text;
}
~ciphere_Text()
{
delete c_Text;
}
};
Brak komentarzy:
Prześlij komentarz