/*This is a c# program
input : 3
output:
1
0 1
0 1 0
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a, i, j, f = 1 ,sp,k;
Console.Write("Enter a number \n");
a = Convert.ToInt32(Console.ReadLine());
sp = a - 1;
for (i = 1; i <= a; i++)
{
for (k = sp; k >= 1; k--)
Console.Write(" ");
for ( j = 1; j <= i; j++)
{
Console.Write(f+" ");
if (f == 1) f = 0;
else f = 1;
}
sp--;
Console.WriteLine();
}
Console.Read();// to hault the screen
}
}
}
input : 3
output:
1
0 1
0 1 0
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a, i, j, f = 1 ,sp,k;
Console.Write("Enter a number \n");
a = Convert.ToInt32(Console.ReadLine());
sp = a - 1;
for (i = 1; i <= a; i++)
{
for (k = sp; k >= 1; k--)
Console.Write(" ");
for ( j = 1; j <= i; j++)
{
Console.Write(f+" ");
if (f == 1) f = 0;
else f = 1;
}
sp--;
Console.WriteLine();
}
Console.Read();// to hault the screen
}
}
}
Comments