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

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

View Full Document Right Arrow Icon
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)
Background image of page 1

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

View Full DocumentRight Arrow Icon
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))
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online