Untitled
user_9831585
plain_text
3 years ago
1.2 kB
11
Indexable
void initialization3()
{
int size1 = 0;
int size2 = 0;
std::cout<<"Enter your size for frist string -> "<<std::endl;
std::cin>>size1;
char* str1 = new char[size1];
fflush(stdin);
std::cout<<"Enter string 1 -> \n";
std::cin.get(str1, size1);
fflush(stdin);
std::cout<<"Enter your size for secund string -> "<<std::endl;
std::cin>>size2;
char* str2 = new char[size2];
std::cout<<"Enter string 2 -> \n";
fflush(stdin);
std::cin.get(str2, size2);
fflush(stdin);
int flag = ress_equal(str1 , str2 , size1 , size2);
if (flag == 1)
{
std::cout<<"The string is equal -> "<<flag<<std::endl;
}
else
std::cout<<"The string is not equal -> "<<flag<<std::endl;
delete[] str1;
delete[] str2;
}
int ress_equal(char* str1 , char* str2 , int size1 , int size2)
{
if (size1 == 0 || size2 == 0)
{
return 0;
}
if (size1 == 1 && size2 == 1)
{
if (str1[0] == str2[0])
{
return 1;
}
}
if (str1[1] == str2[1])
{
return ress_equal(str1 + 1, str2 +1, size1 -1 , size2-1);
}
else
return 0;
return 1;
}Editor is loading...