/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <iostream>
#include <memory>
template<typename Derived>
struct Clonable{
public:
virtual ~Clonable() = default;
std::unique_ptr<Derived> clone(){ return std::unique_ptr<Derived>( vclone() ); }
protected:
virtual Derived* vclone() const = 0;
};
class MyClass : public Clonable<MyClass>{
public:
void print() const { std::cout << "I'm a MyClass!" << std::endl; }
std::unique_ptr<MyClass> clone() { return std::unique_ptr<MyClass>{ vclone() }; }
protected:
virtual MyClass* vclone() const = 0;
};
class Implementation : public MyClass{
public:
virtual Implementation* vclone() const override
{
return new Implementation(*this);
}
};
int main()
{
Implementation impl;
MyClass* a = &impl;
std::unique_ptr<MyClass> b = a->clone();
a->print();
return 0;
}
Modifies the default numeric base for integer I/O.
я уже на третьем телефоне>
ui->actionSwelab_Alfa_1
ui->actionSwelab_Alfa_2
?#include <stdio.h>
#include<iostream>
#include<cstring>
using namespace std;
int search(const char base_string[], const char substr[])
{
int string_length = strlen( base_string );
int substr_lenght = strlen( substr );
int diff = string_length - substr_lenght;
bool find = false;
bool end = false;
int current = 0;
while ( (!end) && (!find) )
{
int counter = 0;
while ( ( base_string[current+counter] == substr [counter] ) && ( counter < substr_lenght) ) counter++;
if (counter == substr_lenght) find=true;
if ( !find ) current++;
if ( current > diff ) { end =true; current=-1; }
}
return current;
}
int main()
{
cout << search("badbarrar", "bar");
return 0;
}
for(int i{0}; i < input.length(); ++i)
сама input как я понимаю не меняется.