Enter the row number: 5
1 2 3 4 5
2 3 4 5 1
3 4 5 1 2
4 5 1 2 3
5 1 2 3 4
1 2 3 4 5
2 3 4 5 1
3 4 5 1 2
4 5 1 2 3
5 1 2 3 4
class Program
{
static void Main(string[] args)
{
int count;
Console.WriteLine("Enter the input row number");
int num = int.Parse(Console.ReadLine());
for (int row = 1;
row <= num; row++)
{
count = row;
for (int coll =
1; coll <= num; coll++)
{
if (row == 1)
{
Console.Write(coll);
}
else
{
if (count == num + 1)
{
count = 1;
Console.Write(count);
count++;
}
else
{
Console.Write(count);
count++;
}
}
}
Console.WriteLine();
}
Console.ReadLine();
}
}
No comments:
Post a Comment