Parkside's Other Triangle

This is a discussion on Parkside's Other Triangle within the C++ Programming forums, part of the General Programming Boards category; Here's what the book says: Parkside's Other Triangle is generated from two positive integers, one for the size and one ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    3

    Parkside's Other Triangle

    Here's what the book says:
    Parkside's Other Triangle is generated from two positive integers, one for the size and one for the seed. For example,

    Size 6, Seed 1

    1 2 4 7 2 7
    3 5 8 3 8
    6 9 4 9
    1 5 1
    6 2
    3

    Size gives the number of columns. Seed specifies the starting value for column 1. Column n contains n values. The successive values are obtained by adding 1 to the previous value. When 9 is reached, the next value becomes 1.
    Write a program that reads pairs of positive integers and produces Parkside's Other Triangle for each pair.



    This is what I have so far:

    Code:
    #include <iostream>
    #include <stdlib.h>
    using namespace std;
    
    int main ()
    {
        int size, seed, LCV;
    
        cout << "Enter the size: ";
        cin >> size;
    
        cout << "Enter the seed: ";
        cin >> seed;
    
       
    
    
        return 0;
    }
    All it does is ask for the size and the seed and you can input the values you want.
    Im supposed to use nested "for" loops to produce the triangle thing in the example i gave above.
    Like:

    for(---;---;---)
    for(---;---;---)
    command;

    I cant use super advanced stuff, all we've learned so far is loops and conditional statements, variables, and basic commands.

    If you can help, Thanks!

  2. #2
    Registered User
    Join Date
    Feb 2009
    Posts
    3
    ugh, it messed up the triangle

    1 2 4 7 2 7
    --3 5 8 3 8
    ----6 9 4 9
    ------1 5 1
    ---------6 2
    -----------3

    Thats how its supposed to look, ignore the dashes

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    http://cboard.cprogramming.com/annou...t.php?f=3&a=39

    And your code won't cut it.

    It's like saying, this is what I have so far -
    Code:
    int main() {
    }

  4. #4
    Registered User
    Join Date
    Feb 2009
    Posts
    3
    Well I added this:

    Code:
    	for(seed; seed <= size; seed++)
    
    	{	
    		cout << seed << " ";
    	}
    Ive got the right number of columns, just the wrong numbers

  5. #5
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Quote Originally Posted by jegland View Post
    Well I added this:

    Code:
    	for(seed; seed <= size; seed++)
    
    	{	
    		cout << seed << " ";
    	}
    Ive got the right number of columns, just the wrong numbers
    Most people use the first part of the for statement to initialize the counter to the proper value
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Recursive Triangle Function
    By w2look in forum C Programming
    Replies: 14
    Last Post: 11-13-2010, 01:31 PM
  2. Right Triangle Program
    By BSmith4740 in forum C# Programming
    Replies: 9
    Last Post: 02-26-2008, 11:24 PM
  3. Stupid Logic Problem Need Outside Viewpoint
    By RP319 in forum C++ Programming
    Replies: 5
    Last Post: 03-03-2005, 09:59 PM
  4. Just in case: "Odd" Triangle Challenge (for me)
    By BB18 in forum C Programming
    Replies: 3
    Last Post: 10-09-2004, 12:02 AM
  5. Determining a Triangle using get and pointer
    By naynay in forum C Programming
    Replies: 7
    Last Post: 04-11-2003, 05:55 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21