Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
CCC 2003 Stage1: J1: Trident
Author Message
Tony

Posted: Sat Mar 22, 2003 12:41 pm   Post subject: CCC 2003 Stage1: J1: Trident

A trident is a fork with three tines (prongs). A simple picture of a trident can be made from asterisks and spaces:
 code: *  *  * *  *  * *  *  * *******    *    *    *    *

In this example, each tine is a vertical column of 3 asterisks. Each tine is separated by 2 spaces. The handle is a vertical column of 4 asterisks below the middle tine.

Tridents of various shapes can be drawn by varying three parameters:
t the height of the tines
s the spaceing between tines
h the length of the handle

for above example we have t=3, s=2 and h=4

You are to write an interactive program to print a trident. Your program should accept as input the parameters t, s, and h, and print the appropriate trident. You can assume that t,s,h are each at least 0 and not larger then 10.

Sample input/output
Enter tine length:
4
Enter tine spacing:
3
Enter handle length:
2
 code: *   *   * *   *   * *   *   * *   *   * *********     *     *

Solution by JSBN

 code: var t : int var s : int var h : int put "Enter tine length:" get t put "Enter tine spacing:" get s put "Enter handle lenght:" get h for i1 : 1 .. t     for i2 : 1 .. 3         put "*" ..         for i3 : 1 .. s             put " " ..         end for     end for     put "" end for if s = 0 then else     for i4 : 1 .. (5 + s * 2) - 2         put "*" ..     end for     put "" end if for i5 : 1 .. h     for i6 : 1 .. s + 1         put " " ..     end for     put "*" end for
Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor

 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 1 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: