#include<stdio.h>
int main()
{
int i,j,k;
int n=5;//size
for(i=1; i<=n; i++)
{
k=(i%2==0)?2:1;
for(j=1; j<=i; j++)
{
printf("%d ",k);
k+=2;
}
printf("\n");
}
}
#include<iostream.h>
int main()
{
int i,j,k;
int n=5;//size
for(i=1;i<=n;i++)
{
k=(i%2==0)?2:1;
for(j=1;j<=i;j++)
{
cout<<k<<" ";
k+=2;
}
cout<<endl;
}
}
public class PatternProg
public static void main(String agrs[]) {
int i;
int j;
int k;
int n = 5; //size
for (i = 1; i <= n; i++) {
k = (i % 2 == 0) ? 2 : 1;
for (j = 1; j <= i; j++) {
System.out.printf("%d ", k);
k += 2;
}
System.out.print("\n");
}
}
}
using System;
public class PatternProg
{
public static void Main(string[] agrs)
{
int i;
int j;
int k;
int n = 5; //size
for (i = 1; i <= n; i++)
{
k = (i % 2 == 0) ? 2 : 1;
for (j = 1; j <= i; j++)
{
Console.Write(k + " ");
k += 2;
}
Console.WriteLine();
}
Console.ReadKey(true);
}
}
n = 5 # size
for x in range(1, n + 1):
if (x % 2 == 0):
k = 2
else:
k = 1
for y in range(1, x + 1):
print(str(k) + " ", end="")
k += 2
print()