PDA

View Full Version : [PBINFO] Problema #188



~Wolf~
02-11-2020, 12:47 PM
Site: pbinfo (<b>You have to register to ba able to see this link</b>)
Link problema: inlocuirecuvant (<b>You have to register to ba able to see this link</b>)

#include <fstream>
#include <cstring>
using namespace std;

ifstream fin("inlocuirecuvant.in");
ofstream fout("inlocuirecuvant.out");

char s[100],c1[10],c2[10],t[100];
char *p;

int main()
{
fin>>c1>>c2;
fin.get();
fin.get(s,100);
p=strtok(s," ");
while(p)
{
if(strcmp(p,c1)==0)
{
strcat(t,c2);
}
else
{
strcat(t,p);
}
strcat(t," ");
p=strtok(NULL," ");
}
fout<<t;
return 0;
}