t3review1 - suit and rank , that store the appropriate...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Review questions for Prelim 3 1. Write the following function: function [len, ind] = longest(C) % Find the longest string(s) in cell array C. % C is an n-by-1 cell array of strings, n>=1. % len is the length of the longest string in C. % ind is a vector, possibly of length one, containing the index number(s) of % the strings with length len 2. Given the following cell arrays of strings: suits= {’Hearts’, ’Clubs’, ’Spades’, ’Diamonds’}; ranks= {’Ace’, ’2’, ’3’, ’4’, ’5’, ’6’, ’7’, ’8’, ’9’, ’10’, ’Jack’, ’Queen’, ’King’}; write a code fragment to Create a structure array of cards such that each structure has two Felds,
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: suit and rank , that store the appropriate strings. The structure array should be of length 52. Do a perfect shue of the cards. 3. Assume that each structure in structure array Pts has two Felds, x and y . Write a code fragment to sort the structure array Pts so that the structures are in the order of increasing distance from (0,0). You can use built-in function sort : [y, idx]= sort(x) where x is an n-vector of numbers , y is x sorted in ascending order, and idx is an n-vector of indices such that y(i) = x(idx(i)) . (Review your notes from Lecture 19 if necessary.) 4. Review the project questions, lecture examples, and section exercises! 1...
View Full Document

This test prep was uploaded on 02/15/2008 for the course CS 100 taught by Professor Fan/vanloan during the Fall '07 term at Cornell University (Engineering School).

Ask a homework question - tutors are online