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

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

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 IDENT, NUMBER, HALT, PLUS, MINUS, MUL, DIV, DOLLAR, LT, LTE, GT, GTE, EQ, NEQ,SEQ, END, READ, WRITE, IF, LPAR,RPAR, JUMPTO, EOLN, JUNK). Write a
Image of page 1

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

Image of page 2
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '08
  • Kay
  • a.out, bool b,char *mess, void check

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern