{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

08-Section-Handout

# 08-Section-Handout - CS106B Winter 2010 Handout 08 Section...

This preview shows pages 1–2. Sign up to view the full content.

CS106B Handout 08 Winter 2010 January 11 th , 2010 Section Handout We haven’t learned so much C++ yet that I can really push you on C++ constructs. The problems below are algorithmically nontrivial, but once you find an algorithm, the solution is near trivial to implement. Think of these as advanced CS106A problems where you’re now required to write in C++ instead of Java. Problem 1: Look And Say The look-and-say sequence is the sequence of numbers beginning as: 1 11 21 1211 111221 312211 13112221 Each number in the sequence is generated by "reciting" its predecessor, and then capturing what was said in a number format that should be clear from the example below. Reciting 111221 out loud, you’d look and say: 3 ones, followed by 2 twos, followed by 1 one, or 312211. Reading 312211 aloud, you’d say: 1 three, 1 one, 2 twos, 2 ones, or 13112221. Even if a number doesn’t fall in the actual sequence, it should be clear how to generate its look-and-say successor. Write a function called LookAndSay , which takes a number in string form, and returns its look-and-say form. You can assume the incoming string contains only digits, and that the longest run of any single digit will be less than or equal to 9. /** * Accepts the incoming string and generates the

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

08-Section-Handout - CS106B Winter 2010 Handout 08 Section...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online