The Swedish Chef is a character from the Muppet Show. He spoke in his own language. The language is a combination of English, mock-Swedish and nonsense. Your task is to create an English to Chef translator. The language rules in priority order are as follows:
Rezolvată pentru partea cu BORK, pentru înlocuirea unui caracter cu un altul şi a unui şir cu un altul.
#include<iostream.h>
#include<fstream.h>
char a[]=" BORK BORK BORK!",s[100];
void BORK(char s[])
{strcat(s,a);}
void f10(char s[],char c1,char c2)
{char *p;
while(p=strchr(s,c1))
s[p-s]=c2;
}
void f2(char s[],char t[],char u[])
{int a=strlen(t);
char v[100],*p;
v[0]=NULL;
while(p=strstr(s,t))
{strcpy(v,s);
v[p-s]='\0';
strcat(v,u);
strcat(v,p+a);
strcpy(s,v);
v[0]=NULL;}
}
void f4(char s[],char t[],char u[])
{int a=strlen(t);
char v[100],*p;
v[0]=NULL;
while(p=strstr(s+1,t))
if(s[p-s-1]!=' ')
{strcpy(v,s);
v[p-s]=NULL;
strcat(v,u);
strcat(v,p+a);
strcpy(s,v);
v[0]=NULL;}
}
void FF(char s[])
{char v[100];
int i,j=0;
v[0]=NULL;
for(i=0;i<strlen(s);i++)
if(s[i]=='F')
{v[j]='F';
v[j+1]='F';
j+=2;}
else
{v[j]=s[i];
j++;}
v[j]=NULL;
strcpy(s,v);
}
void f5(char s[])
{char v[100];
int i,j=0;
v[0]=NULL;
for(i=0;i<strlen(s);i++)
if(s[i]=='A' && (s[i+1]!=' ' && s[i+1]!='.'))
{v[j]='E';j++;}
else {v[j]=s[i];j++;}
v[j]=NULL;
strcpy(s,v);
}
void f3(char s[])
{char v[100];
int i,j=0;
v[0]=NULL;
for(i=0;i<strlen(s);i++)
if(s[i]=='E' && (s[i+1]==' ' || s[i+1]=='.'))
{v[j]='E';j++;
v[j]='-';j++;
v[j]='A';j++;}
else {v[j]=s[i];j++;}
v[j]=NULL;
strcpy(s,v);
}
void f6(char s[])
{char v[100];
int i,j=0;
v[0]=NULL;
for(i=0;i<strlen(s);i++)
if(s[i]=='U' && s[i-1]!=' ' && i-1!=-1)
{v[j]='O';j++;
v[j]='O';j++;}
else {v[j]=s[i];j++;}
v[j]=NULL;
strcpy(s,v);
}
int main()
{
ifstream f("date.in");
ofstream g("date.out");
int n,i;
f>>n;
f.get();
for(i=0;i<n;i++)
{
f.getline(s,100);
f2(s,"THE","ZEE");
f2(s,"AN","UN");
f2(s,"AU","OO");
f5(s);
f2(s,"OW","OO");
f2(s,"O","U");
f2(s,"IR","UR");
f2(s,"TION","SHUN");
f4(s,"I","EE");
f2(s,"EN","EE");
FF(s);
f3(s);
f6(s);
f2(s,"V","F");
f2(s,"W","V");
BORK(s);
g<<s<<endl;
}
}