Login to ZARP
|
Its not urgent but I am having issues, I am currently learning how to code C#.
My exercise is to write a program that draws a triangle of numbers from 1 to Max (chosen by the user, Max must be a positive number) with for each of them the numbers that precede them (up to 1). Please don't call me stupid when I am about to show the program that I done: { Console.WriteLine("Jusqu'a quel nombre?"); nb1 = Convert.ToInt32(Console.ReadLine()); for (i = nb1; i <= nb1; i = nb1 - 1 ) { for (f = 1; i <= f; f++) { Console.Write(nb1); } Console.Write("\n"); } } I know this is hella wrong, but I am learning. If you are good at coding C# it would be nice that you explain to me. That would be epic. |
|
The topic has been locked.
|
@Deadmonstor
|
|
The topic has been locked.
|
I think this is what you're trying to do
using System;
namespace NumberTriangle
{
class Program
{
static void Main(string[] args)
{
Console.Write("Max Number: ");
int max = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i <= max; i++)
{
if (i == max) { break; }
else
{
for (int f = 0; f < i; f++)
{
Console.Write(i);
}
Console.Write("\n");
}
}
Console.ReadLine();
}
}
} |
|
Last Edit: 5 years 1 month ago by bunnyslippers69.
The topic has been locked.
The following user(s) said Thank You: PoseidonEUW
|
Thanks man! Really appreciate it. I will give you a thumbs up right now
|
|
The topic has been locked.
|
You can close this post ^_^.
|
|
The topic has been locked.
|