# 07 - CS1371 Recitation10/7 TEST Structures FileI/O...

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

CS1371 Recitation 10/7 TEST -Structures -File I/O -Recursion -Arrays -Plotting -Bodies of Rotation -Anything HW 1-8 ---------------------------------- Mini-quiz: write recursive function rmult(a,b) that uses only addition and subtraction to multiply a by b. function ret = rmult(a,b) if b == 0 ret = 0 else ret = a + rmult(a, b-1) end ----------------------------------- Function Wrapper - putting several functions together function ret = rmultin(a, b) if b== 0 ret = 0 else ret = a + rmultin(a, b-1) function ret = rmult(a,b) if a < 0 if b < 0 ret = rmult(-a, -b) else ret = -rmultin(-a, b) end elseif b < 0 ret = -rmultin(a, -b)

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

View Full Document
elseif b == 0 || a == 0 ret = 0 end ---------------------------------------- function logout = isPalindrome(str) str(str==32) = [ ] str = lower(str) logout=innerisPalindrome(str) end function logout = innerisPalindrome(str) if length(str)==1||isempty(str) logout = true elseif str(1)==str(end) logout = innerisPalindrome(str(2:end-1))
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 4

07 - CS1371 Recitation10/7 TEST Structures FileI/O...

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

View Full Document
Ask a homework question - tutors are online