Facebook
From Sweltering Porcupine, 4 Years ago, written in C++.
This paste is a reply to Re: Untitled from Bistre Macaw - go back
Embed
Viewing differences between Re: Untitled and Re: Re: Untitled
#include 
#include 

using namespace std;

string& and_(string& s, const string& s1, const string& s2) 
s2)//Передаем все по константной ссылке, поточу что строчки тяжелые
{
        if (s1.length()> s1.length())
length())//В зависимости от длины строк сравниваем их посимвольно в цикле, костыль ебагный
        {
                for (int i = 0; i < s1.length(); i++)
                {
                        if (s1[i]==s2[i])
                        {
                                s += s1[i];
                        }
                }
                return s;
        }
        else
        {
                for (int i = 0; i < s2.length(); i++)
                {
                        if (s1[i] == s2[i])
                        {
                                s += s2[i];
                        }
                }
                return s;
        }
        
}
int main()
{
        char* str_temp = new char[255];
        string* s = new string[255];
        
string[255];//Динамическая ин-я
        
string s1 = "Hello";
"Hello";//Сами строки
        string s2 = "Hell";

        cout << and_(*s, s1, s2) << endl;
endl;//Юзаем функцию
        return 0;
}