Mercurial > repo
changeset 7893:56fc659cb1e2
<shachaf> ` mv ReUariBw junk/
author | HackBot |
---|---|
date | Fri, 06 May 2016 23:31:46 +0000 |
parents | 12cea206af03 |
children | 79483b0670e8 |
files | ReUariBw junk/ReUariBw |
diffstat | 2 files changed, 65 insertions(+), 65 deletions(-) [+] |
line wrap: on
line diff
--- a/ReUariBw Fri May 06 23:31:21 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/junk/ReUariBw Fri May 06 23:31:46 2016 +0000 @@ -0,0 +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; +} \ No newline at end of file