Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using std::cin,std::cout,std::endl,std::string;
- // -std=c++17
- bool is_upper(string *word,int el)
- {
- for(int c=0;c<word[el].size();c++){
- if(std::isupper(static_cast<unsigned char>(word[el][c]))){ return true;
- }
- }
- return false;
- }
- void start_mess(){
- cout
- <<"This program seeks for a substring within"
- <<" another string. First enter the sub-string"
- <<" then the string to be searched."
- <<endl
- <<endl
- <<"BUT FIRST:"
- <<endl
- <<"Enter amount of test cases to be done"<<endl;
- }
- void sub_string_mess(){
- cout<<"enter possable substring"<<endl;
- }
- void search_string_mess(){
- cout<<"enter string to be searched"<<endl;
- }
- void upper_case_err_mess(){
- cout<<endl<<"ALL TEXT HAS TO BE <lowercase>!"
- <<endl
- <<"and or under 1001 chars."
- <<endl
- <<"You figure out what you did wrong. I'm just a computer."
- <<endl<<endl;
- }
- int main(){
- /* MAX TEST 100 */
- string strA[100]={"SCOOBIE"},strB[100]={"DOO"};
- string sub,search;
- int test_case=0,tested=1;
- char testing='y';
- int ct2=0;
- int ct1=0;
- // get amount of test control loop
- while(testing == 'y'){
- start_mess();
- cin>>test_case;
- if(!cin){
- std::cin.clear();
- std::cin.ignore(std::numeric_limits<
- std::streamsize>::max(), '\n');
- std::cerr<<endl<<"Bad input"<<endl<<endl;
- continue;
- }
- else if(test_case<=0 || test_case>100){
- cout<<"does not meet the requirments\n"
- <<"limits 1-100 tests"<<endl;
- continue;
- } // end i
- else{
- testing='n';
- } // end else
- } // end testing loop
- // get strings control loop
- char gs='y';
- while(gs=='y'){
- char sbs='y';
- while(sbs=='y'){
- //sub_string_mess();
- /*skips over these functions */
- //getline(cin,strA);
- //cin.getline(strA,1000);
- cin>>strA[ct1];
- if(is_upper(strA,ct1) ||
- strA[ct1].size()>1000 ||
- strA[ct1].size()<1) {
- upper_case_err_mess();
- continue;
- }
- else{
- sbs='n';
- }
- }// end sub string for
- char ss='y';
- while(ss=='y'){
- //search_string_mess();
- /* skips over these functions */
- //cin.getline(strB,1000);
- //getline(cin,strB);
- cin>>strB[ct2];
- if(is_upper(strB,ct2) ||
- strB[ct2].size()<1 ||
- strB[ct2].size()>1000){
- upper_case_err_mess();
- continue;
- } // end if
- else
- ss='n';
- } // end for
- // stop loop check
- if((tested++)>=test_case){
- gs='n';
- }
- else{ // reset srting gathering
- sbs='y';
- ss='y';
- ct1++;
- ct2++;
- } // end else
- } // end control loop
- cout<<endl<<endl<<endl;
- for(int a=0;a<test_case;a++){
- /*
- cout<<endl<<strA[a]<<endl
- <<strB[a]<<endl;
- */
- strB[a].find(strA[a]) != string::npos ?
- cout<<"YES"<<endl:cout<<"NO"<<endl;
- }
- cout<<"one more time using a different methiod"<<endl<<endl;
- for(int d=0;d<test_case;d++){
- strB[d].find(strA[d].c_str(), strA[d].size()) != string::npos ?
- cout
- <<endl
- << " Yep "
- <<endl :
- cout << " nope "
- << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment