Presentation is loading. Please wait.

Presentation is loading. Please wait.

March 2005 1R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Revised Lab 14/15Revised Lab 14/15 Counting WordsCounting Words Moving.

Similar presentations


Presentation on theme: "March 2005 1R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Revised Lab 14/15Revised Lab 14/15 Counting WordsCounting Words Moving."— Presentation transcript:

1 March 2005 1R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Revised Lab 14/15Revised Lab 14/15 Counting WordsCounting Words Moving Words/TextMoving Words/Text

2 March 2005 2R. Smith - University of St Thomas - Minnesota Labs 14 and 15 Lab 14 is Pig Latin for vowels onlyLab 14 is Pig Latin for vowels only –add ‘way’ to end of words that start with vowels Lab 15 is ‘full’ Pig LatinLab 15 is ‘full’ Pig Latin –The original Lab

3 March 2005 3R. Smith - University of St Thomas - Minnesota Preliminary Tasks Use ‘word count’ as a way to develop and test functions we will need for Pig LatinUse ‘word count’ as a way to develop and test functions we will need for Pig Latin Phase 1: Count WordsPhase 1: Count Words Phase 2: Count and copy wordsPhase 2: Count and copy words

4 March 2005 4R. Smith - University of St Thomas - Minnesota Counting Words Useful FunctionsUseful Functions –readline – our old friend –wordstart – find start of next word –wordend – find end of current word –countwords – count the words –main – our ‘skeleton’ Solving the problem: countwords()Solving the problem: countwords() –#include –#include –isalpha() –Others on page 473

5 March 2005 5R. Smith - University of St Thomas - Minnesota Solving the problem: countwords() –Read a line of text –A loop to find words Find start of a wordFind start of a word Count itCount it Find end of wordFind end of word RepeatRepeat

6 March 2005 6R. Smith - University of St Thomas - Minnesota Moving Words Going back to our ‘movewords’ functionGoing back to our ‘movewords’ function The process for handling a line of textThe process for handling a line of text –Start at the beginning of the line –Find start of next word –If there is text before the word, copy it to the output –Find end of the word –Count a word –Copy the word to the output –Repeat the loop Use our ‘movetext’ functionUse our ‘movetext’ function

7 March 2005 7R. Smith - University of St Thomas - Minnesota Creative Commons License This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by- sa/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.


Download ppt "March 2005 1R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Revised Lab 14/15Revised Lab 14/15 Counting WordsCounting Words Moving."

Similar presentations


Ads by Google