Skip to content

Instantly share code, notes, and snippets.

@rohanrajpal
Created July 29, 2019 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rohanrajpal/59e120df13ca7329638a990dc2cf988f to your computer and use it in GitHub Desktop.
Save rohanrajpal/59e120df13ca7329638a990dc2cf988f to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
struct Result{
char* output[100];
};
Result res;
void autocorrect(char *input1,char *input2)
{
int str_length = 0;
string s1 = input1;
string s2 = input2;
unsigned int ptr = 0;
int cur =0;
while(ptr<s1.size())
{
string temp;
while(ptr<s1.size() && s1[ptr]!=' ')
{
temp.push_back(s1[ptr]);
ptr++;
}
if(temp.substr(0,s2.size()) == s2 )
{
res.output[cur] = (char* )malloc(10);
strcpy(res.output[cur],temp.c_str());
cur++;
}
ptr++;
}
}
int main()
{
#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif
char input1[1000],input2[100];
cin.getline(input1,1000);
cin.getline(input2,100);
autocorrect(input1,input2);
for(int i=0;i<100;i++){
cout<<res.output[i]<<"\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment