c109f07t2 - CSE 109 Test 1 Wednesday 14 November 2007...

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

View Full Document Right Arrow Icon
CSE 109 Test 1 Wednesday 14 November 2007 >>>>>>>>>>>>>>>>>>>>>>>>>>SUGGESTED ANSWERS<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 1. Write a program that determines whether the strings entered on the command line are in descending lexicographical order. If the compiled program is stored in a.out, then the following commands would produce the output that appears on the line following the command. a a.out In order by default a.out p In order by default a.out bear Bear Ant In order a.out b b ant In order a.out able baker are Out of order >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #include "word.cc" /*descending order*/ int main(int ct,char**sym){ if(ct<3){ cout<<"In order by default\n"; return 0; } ct--; while(ct>1){ // if(strcmp(sym[ct],sym[ct-1])>0){ //either of these works if(Word(sym[ct])>Word(sym[ct-1])){ cout<<"Out of order\n"; return 0; } ct--; } cout<<"In order\n"; } <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< < 2. Assume you have available in the lex.h the declaration for the class Lex, a lexical analyzer for the SPL++ language (recall the constants
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/09/2008 for the course CSE 109 taught by Professor Kay during the Spring '08 term at Lehigh University .

Page1 / 3

c109f07t2 - CSE 109 Test 1 Wednesday 14 November 2007...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online