Jump to content

Reversing my pattern

- - - - -

  • Please log in to reply
2 replies to this topic

#1
spkenn5

spkenn5

    Newbie

  • Members
  • Pip
  • 9 posts
hi guys im not that good at the logic.. i wonder if you can help me and guide me through this.. i hope you can teach me the logic too.. so i've got the code to make a triangle of # of input.

to make things short, here it is:

	for(int i = 0; i < 25; i++)

	{

		if(i == 24)

			{

				printf("Press enter to continue");

				getchar();

				break;

			}

		for(int j = 0; j < 80; j++)

		{

		

					if(i%input == j%input)

					{

						printf("*");

					}else 

						printf(" ");

					

		}


	}

the input you put is to print the distance between each stars horizontally and vertically..

so far i did the \ shape, i dont know how do i suppose to do the shape of "/ " and " X " and boxed X, |X|

thanks

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Can you give a more detailed example of what output you're trying to generate? I suspect the / will help you figure out the others.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
spkenn5

spkenn5

    Newbie

  • Members
  • Pip
  • 9 posts
nvm guys, i found it through trial and error

		for(int i = 0; i < 25; i++)

	{

		if(i == 24)

			{

				printf("Press enter to continue");

				getchar();

				break;

			}

		for(int j = 0; j < 80; j++)

		{

			if((j + (i % input)) % input== 0)

					{

						printf("*");

					}else

						printf(" ");

		}

	}

thanks again




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users