1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
/* Pig latin....?
*/
#include <conio.h>
#include <iostream.h>
#include <string.h>
main()
{
//Declare variables
char word[31]="";
char newword[31]="";
char twoletter[3]="";
char quit[2]="";
int length=0, i=0;
do
{
cout<< "Enter the phrase or word you wish to translate." <<endl;
cin.get(word,31);
cin.ignore(80,'\n');
length=strlen(word); //Get the length!
//Now... To translate it
if (word[0]=='a'||'e'||'i'||'o'||'u')
{
strcat(word,"way");
strcpy(newword, word);
}
else
{
strcat(twoletter, word[0]);
strcat(twoletter, word[1]);
if (twoletter == 'bl'||'br'||'ch'||'cl'||'cr'||'dr'||'dw'||'fl'||'fr'||'gl'||'gr'||'kl'||'ph'||'pl'||'pr'||'sc'||'sh'||'sk'||'sl'||'sn'||'sm'||'sp'||'sq'||'st'||'sw'||'th'||'tr'||'tw'||'wh'||'wr')
{
strcat(word, twoletter);
strcat(word, "ay");
strcpy(newword, word);
}
else
{
for(i<length-1; word[i]=word[i+1],i++)
strcat (word,word[0]);
strcat (word, "ay" );
strcpy (newword, word);
}
}
cout<<newword<<endl;
cout<< "To close this program, enter the word 'quit'."<< endl;
cin >> quit;
cin.ignore(80,'\n');
}while (strcmp(quit,'q')==0);
}
getch();
return 0;
|