Amazon.com Widgets Chapter 8 - Easier than I thought...
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 19, 2013, 01:51:16 PM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Old Stuff
| |-+  Answers to Exercises
| | |-+  Chapter 8
| | | |-+  Chapter 8 - Easier than I thought...
Pages: [1]   Go Down
Print
Author Topic: Chapter 8 - Easier than I thought...  (Read 434 times)
johnyorke
Newbie
*
Posts: 18


Email




« on: April 03, 2012, 12:36:48 PM »

Tested and it seems to work. Feedback welcome.
Code: (Objective-C)
-(void) draw
{
    // Draw top of rectangle
    float n,s;
    for (n = 1; n <= width; n++) {
        printf("-");
    }
    printf("\n"); // Line break
   
    // Draw sides "|" (spaces = width - 2) "|" \line break
    for (n = 1; n <= height; n++) {
        printf("|");
        // To determine number of spaces
        for (s = 1; s <= (width - 2); s++) {
            printf(" ");
        }
    printf("|\n");
    }
   
    // Draw bottom (same as top)
    for (n = 1; n <= width; n++) {
    printf("-");
    }
}
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.