Thread: need a lil help with some loops

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    40

    need a lil help with some loops

    ok here;s my code:

    Code:
    #include <stdio.h>
    
    main()
    {
      int shape1, shape2, shape3, shape4, shape5;
      int base1, base2, base3, base4, base5;
      int height1, height2, height3, height4, height5;
      int rot1, rot2, rot3, rot4, rot5;
      int row, col;
      int space, t, s;
    
      printf("Shapes\n\n");
      scanf("%d%d%d%d", &shape1, &base1, &height1, &rot1); 
    /* ok heres the inputs for the base and height */
    
    
    
      if(shape1 == 1 || shape1 == 2)
        {
          if(shape1 == 1)
            {
              /* pyramid */
                  for (row = 1; row <= height1; row++)
                    {
                      for (space = height1; space >= row; space--)
                        printf(" ");
                      for (col = 1; col <= (row * 2 - 1); col++)
                        printf("*");
                      printf("\n");
                    }
            }
          else
            {
              /* top */
                  for (row = 1; row <= height1; row++)
                    {
                      for (space = height1; space >= row; space--)
                        printf(" ");
                      for (col = 1; col <= (row * 2 - 1); col++)
                        printf("*");
                      printf("\n");
                    }
              /* bottom of diamond */
                  for (row = 1; row <= height1 - 1; row++)
                    {
                      for (space = 1; space <= row + 1; space++)
                        printf(" ");
                      for (col = 1; col <= height1 * 2 - (row * 2 + 1); col++)
                        printf("*");
                      printf("\n");
                    }
            }
    
        }
    
      return 0;
    }
    and the output for input: 1 5 6 0 is:

    Code:
          *
         ***
        *****
       *******
      *********
     ***********
    which isn't right, i can't figure out what i need to change to make ti work, can anyone help me out some?
    Last edited by blindleaf; 03-16-2003 at 03:17 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Loops Trouble
    By rlframpton in forum C Programming
    Replies: 2
    Last Post: 04-17-2009, 01:08 AM
  2. Too many loops D:
    By F5 Tornado in forum C++ Programming
    Replies: 6
    Last Post: 12-03-2007, 01:18 AM
  3. Evaluation of nested loops
    By Mister C in forum C Programming
    Replies: 2
    Last Post: 08-13-2004, 01:47 PM
  4. help with arrays and loops
    By jdiazj1 in forum C Programming
    Replies: 4
    Last Post: 11-24-2001, 04:28 PM
  5. exiting loops with ease?
    By KingRuss in forum Game Programming
    Replies: 3
    Last Post: 09-24-2001, 08:46 PM