eolymp
bolt
Try our new interface for solving problems
Problems

startsWith endsWith

published at 1/17/24, 6:51:07 pm

include <bits/stdc++.h>

define ll long long

define ld long double

using namespace std; int main(){

iosbase::syncwith_stdio(0); cin.tie(0); cout.tie(0); string s,a,b; cin>>s>>a>>b; int a1 = a.size(); int s1 = s.size(); int b1 = b.size(); string s2 = s.substr(0,a1); if(s2 == a) cout<<"true"<<endl; else cout<<"false"<<endl; string s3 = s.substr(s1-b1,b1); if(s3 == b) cout<<"true"<<endl; else cout<<"false"<<endl;

}//hahaha

published at 1/20/24, 2:31:46 pm

include <bits/stdc++.h>

using namespace std;

int main () {

string s, s1, s2;

cin >> s;

cin >> s1;

cin >> s2;

long long say1 = 0, say2 = 0, z = s.size () - 1;;

for (int i = 0; i < s1.size (); i++) {

if (s[i] == s1[i]) {

say1++;

}

}

for (int i = s2.size () - 1; i >= 0; i--) {

if (s[z] == s2[i]) {

say2++;

}

z--;

}

if (say1 == s1.size ()and say2 == s2.size ()) {

cout << "true" << endl;

cout << "true" << endl;

}

else if (say1 == s1.size ()and say2 != s2.size ()) {

cout << "true" << endl;

cout << "false" << endl;

}

else if (say1 != s1.size ()and say2 == s2.size ()) {

cout << "false" << endl;

cout << "true" << endl;

}

else if (say1 != s1.size ()and say2 != s2.size ()) {

cout << "false" << endl;

cout << "false" << endl;

}

}