using System;
namespace MyCompiler {
class Program {
public static void Main(string[] args) {
// pattern1(4);
// pattern2(5);
// pattern3(5);
// pattern4(5);
// pattern5(5);
// pattern6(5);
// pattern7(5);
// pattern8(5);
// pattern9(4);
// pattern10(4);
}
static void pattern1(int n){
//Number of rows in the pattern
for(int row=1;row<=n;row++){
//number of column in each row
for(int col=1;col<=n;col++){
Console.Write("* ");
}
//when one line is printed we need to add one new line
Console.WriteLine(" ");
}
}
static void pattern2(int n){
//Number of rows in the pattern
for(int row=1;row<=n;row++){
//number of column in each row
for(int col=1;col<=row;col++){
Console.Write("* ");
}
//when one line is printed we need to add one new line
Console.WriteLine(" ");
}
}
static void pattern3(int n){
//Number of rows in the pattern
for(int row=0;row<=n;row++){
//number of column in each row
for(int col=1;col<=n-row+1;col++){
Console.Write("* ");
}
//when one line is printed we need to add one new line
Console.WriteLine(" ");
}
}
static void pattern4(int n){
//Number of rows in the pattern
for(int row=1;row<=n;row++){
//number of column in each row
for(int col=1;col<=row;col++){
Console.Write(col);
}
//when one line is printed we need to add one new line
Console.WriteLine(" ");
}
}
static void pattern5(int n){
//Number of rows in the pattern
for(int row=0;row<2*n;row++){
int totalcol;
if(row > n){
totalcol = (2*n) - row;
}else{
totalcol = row;
}
//number of column in each row
for(int col=1;col<=totalcol;col++){
Console.Write("* ");
}
//when one line is printed we need to add one new line
Console.WriteLine(" ");
}
}
//upper+lower triangle
static void pattern6(int n){
//Number of rows in the pattern
for(int row=0;row<2*n;row++){
int totalcol;
if(row > n){
totalcol = (2*n) - row;
}else{
totalcol = row;
}
int spaces = n - totalcol;
//Print total number of spaces
for(int spa=0;spa<spaces;spa++){
Console.Write(" ");
}
//number of column in each row
for(int col=0;col<totalcol;col++){
Console.Write("* ");
}
//when one line is printed we need to add one new line
Console.WriteLine(" ");
}
}
//upper triangle
static void pattern7(int n){
//Number of rows in the pattern
for(int row=0;row<=n;row++){
int totalcol;
// if(row > n){
// totalcol = (2*n) - row;
// }else{
// totalcol = row;
// }
int spaces = n - row;
//Print total number of spaces
for(int spa=0;spa<spaces;spa++){
Console.Write(" ");
}
//number of column in each row
for(int col=0;col<row;col++){
Console.Write("* ");
}
//when one line is printed we need to add one new line
Console.WriteLine(" ");
}
}
//lower triangle
static void pattern8(int n){
//Number of rows in the pattern
for(int row=0;row<=n;row++){
int totalcol;
int spaces = n - (n-row);
//Print total number of spaces
for(int spa=0;spa<spaces;spa++){
Console.Write(" ");
}
//number of column in each row
for(int col=0;col<n-row;col++){
Console.Write("* ");
}
//when one line is printed we need to add one new line
Console.WriteLine(" ");
}
}
static void pattern9(int n){
//Number of rows in the pattern
for(int row=1;row<=n;row++){
int spaces = n - row;
//Print total number of spaces
for(int spa=0;spa<spaces;spa++){
Console.Write(" ");
}
//number of column in each row
for(int col=row;col>=1;col--){
Console.Write(col + " ");
}
//number of column in each row
for(int col=2;col<=row;col++){
Console.Write(col + " ");
}
//when one line is printed we need to add one new line
Console.WriteLine(" ");
}
}
//Number Upside down triangle print
static void pattern10(int n){
//Number of rows in the pattern
for(int row=1;row<=2*n-1;row++){
int totalCol;
if(row>n){
totalCol=(2*n - row);
}else{
totalCol = row;
}
int spaces = n - totalCol;
//Print total number of spaces
for(int spa=0;spa<spaces;spa++){
Console.Write(" ");
}
//number of column in each row
for(int col=totalCol;col>=1;col--){
Console.Write(col + " ");
}
//number of column in each row
for(int col=2;col<=totalCol;col++){
Console.Write(col + " ");
}
//when one line is printed we need to add one new line
Console.WriteLine(" ");
}
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: