By GokiSoft.com| 10:08 05/10/2021|
C Sharp

Hiển thị hình tam giác - Lập trình C# - Loop trong C#

Thực hiện vẽ hình sau

* * * * * *

* * * * *

* * * *

* * *

* *

*

Độ cao N = 6

Yêu cầu nhập N từ bàn phím. Hiển thị ra hình tương tự trên vs độ cao N

Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

Triệu Văn Lăng [T2008A]
Triệu Văn Lăng

2021-05-17 08:18:46



using System;

namespace bai1398
{
    class TamGiacSao
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Console.WriteLine("Ve tam giac hinh sao");
            int n, i, j;
            Console.WriteLine("Nhap n: ");
            n = Convert.ToInt32(Console.ReadLine());

            for(i = n; i >= 1; i--)
            {
                for (j = 1; j <= i; j++)
                
                    Console.Write("* ");
                    Console.WriteLine("\n");
                
            }
            Console.ReadKey();
        }
    }
}



hainguyen [T2008A]
hainguyen

2021-05-17 08:07:29



using System;

namespace Lesson02
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            N = Int32.Parse(Console.ReadLine());
            for (int i = N; i > 0; i--)
            {
                for (int j = 0; j < i; j++)
                {
                    Console.WriteLine("*");
                }
                Console.WriteLine("\n");
            }
        }
    }
}



Trần Văn Lâm [T2008A]
Trần Văn Lâm

2021-05-17 08:04:44




{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; i < 6; i++) { 
                for(int j = 0; j <6-i; j++)
                {
                    Console.WriteLine("*");
                }
                Console.WriteLine("\n");
            }
            Console.ReadKey();
        }
    }
}



Nguyễn Tiến Đạt [T2008A]
Nguyễn Tiến Đạt

2021-05-17 07:56:33



using System;

namespace InHinhTamGiac
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            N = Int32.Parse(Console.ReadLine());
            for(int i = N; i > 0; i--)
            {
                for(int j = 0; j < i; j++)
                {
                    Console.Write("*");
                }
                Console.WriteLine();
            }
        }
    }
}



Nguyễn Hoàng Anh [C1907L]
Nguyễn Hoàng Anh

2020-06-25 12:26:31



using System;
using System.Collections.Generic;
using System.Text;

namespace Lession1
{
    class Class3
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Nhap vao n :");
            int n = int.Parse(Console.ReadLine());
            for (int i = n; i >= 0; i--)
            {
                for (int j = 0; j < i; j++)
                {
                    Console.Write("*");
                }
                Console.Write("\n");
            }
        }
    }
}



Ngô Quang Huy [C1907L]
Ngô Quang Huy

2020-06-24 14:02:45



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace bait
{
    class Program
    {
        static void Main(string[] args)
        {
            for(int i = 0; i < 6; i++)
            {
                for (int j = 0; j< 6-i; j++){
                    Console.Write("*");
                }
                Console.Write("\n");

            }
            Console.Read();
        }
    }
}



trung [C1907L]
trung

2020-06-24 13:54:58



using System;

class MainClass {
  public static void Main (string[] args) {
    int x = int.Parse(Console.ReadLine());
    while (x >= 1)
    {
      string str = "";
      for (int i = 0; i < x; i++)
      {
        str += "* ";
      }
      str += "\n";
      Console.WriteLine(str);
      x--;
    }
  }
}



Lê Minh Bắc [T1907A]
Lê Minh Bắc

2020-05-19 04:21:08



using System;

namespace Lession2
{
    class Tamgiac
    {
        static void Main(string[] args)
        {
            Console.Write("Nhap N: ");
            int n = int.Parse(Console.ReadLine());

            for (int i = n; i > 0; i--)
            {
                for (int j = 1; j <= i; j++)
                {
                    Console.Write(" * ");
                }
                Console.Write("\n");
            }
            Console.ReadKey();

        }
    }
}



lê văn phương [T1907A]
lê văn phương

2020-05-19 03:46:56



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HienThiHinhTamGiac
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.Write("Mời bạn nhập số hàng: ");
            int h = int.Parse(Console.ReadLine());

            for (int i = h; i > 0; i--)
            {
                for (int j = 1; j <= i; j++)
                {
                    Console.Write(" * ");
                }
                Console.Write("\n");
            }
            Console.ReadKey();
            
        }
    }
}



Phan Bạch Tùng Dương [T1907A]
Phan Bạch Tùng Dương

2020-05-19 02:10:39



using System;

namespace Ls4
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 6; i >= 1; i--)
            {
                for (int k = i; k >= 1; k--)
                {
                    Console.Write("*");
                }
                Console.WriteLine("\n");
            }
        }
    }   
}