# HG changeset patch # User HackBot # Date 1462581578 0 # Node ID 355ec96b89df67e5cf95b23f14b1e66c32ae38d4 # Parent bb911493ba6186b92fe5275ba08124aff42cc6fe ` dos2unix junk/ReUariBw; cat junk/ReUariBw diff -r bb911493ba61 -r 355ec96b89df junk/ReUariBw --- a/junk/ReUariBw Sat May 07 00:37:39 2016 +0000 +++ b/junk/ReUariBw Sat May 07 00:39:38 2016 +0000 @@ -1,65 +1,65 @@ -int main( int argc, char *argv[] ) { - int words = countwords(argv[1]); - char english[80], piglatin[80]; - initialize(english, piglatin); - words = countwords(english); - - /* Now Pig Latin Translator in C converts English to Pig Latin */ - convert(words, english, piglatin); - writeoutput(piglatin); -} -int countwords(char english[]) -{ - int count, words = 1; - for (count = 0; count < 79; ++count) - if (english[count] == ' ' && english[count + 1] != ' ') - ++words; - return (words); -} -void initialize(char english[], char piglatin[]) -{ - int count; - for (count = 0; count < 80; ++count) - english[count] = piglatin[count] = ' '; - return; -} - - - -/* now Pig Latin translator in C coverts each word into Pig Latin */ -void convert(int words, char english[], char piglatin[]) -{ - int n, count; - int m1 = 0; /* m1 indicates the position of beginning of each word */ - int m2; /* m2 indicates the end of the word */ - - /* convert each word */ - for (n = 1; n <= words; ++n) - { - /* locating the end of the current word */ - count = m1 ; - while (english[count] != ' ') - m2 = count++; - - /* transposing the first letter of each word and adding 'a' at the end */ - for (count = m1 ; count < m2; ++count) - piglatin[count + (n - 1)] = english[count + 1]; - piglatin[m2 + (n - 1)] = english[m1]; - piglatin[m2 + n] = 'a'; /* adding 'a' at the end */ - - /* reseting the initial marker */ - m1 = m2 + 2; - } - return; -} - - -/* now Pig Latin translator in C displays the line of English text in Pig Latin */ -void writeoutput(char piglatin[]) -{ - int count = 0; - for (count = 0; count < 80; ++count) - putchar(piglatin[count]); - printf("\n"); - return; +int main( int argc, char *argv[] ) { + int words = countwords(argv[1]); + char english[80], piglatin[80]; + initialize(english, piglatin); + words = countwords(english); + + /* Now Pig Latin Translator in C converts English to Pig Latin */ + convert(words, english, piglatin); + writeoutput(piglatin); +} +int countwords(char english[]) +{ + int count, words = 1; + for (count = 0; count < 79; ++count) + if (english[count] == ' ' && english[count + 1] != ' ') + ++words; + return (words); +} +void initialize(char english[], char piglatin[]) +{ + int count; + for (count = 0; count < 80; ++count) + english[count] = piglatin[count] = ' '; + return; +} + + + +/* now Pig Latin translator in C coverts each word into Pig Latin */ +void convert(int words, char english[], char piglatin[]) +{ + int n, count; + int m1 = 0; /* m1 indicates the position of beginning of each word */ + int m2; /* m2 indicates the end of the word */ + + /* convert each word */ + for (n = 1; n <= words; ++n) + { + /* locating the end of the current word */ + count = m1 ; + while (english[count] != ' ') + m2 = count++; + + /* transposing the first letter of each word and adding 'a' at the end */ + for (count = m1 ; count < m2; ++count) + piglatin[count + (n - 1)] = english[count + 1]; + piglatin[m2 + (n - 1)] = english[m1]; + piglatin[m2 + n] = 'a'; /* adding 'a' at the end */ + + /* reseting the initial marker */ + m1 = m2 + 2; + } + return; +} + + +/* now Pig Latin translator in C displays the line of English text in Pig Latin */ +void writeoutput(char piglatin[]) +{ + int count = 0; + for (count = 0; count < 80; ++count) + putchar(piglatin[count]); + printf("\n"); + return; } \ No newline at end of file