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
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
![Trần Việt Đức Anh [C2010L]](https://www.gravatar.com/avatar/caee507e11365ca2cf5068cbea5c740a.jpg?s=80&d=mm&r=g)
Trần Việt Đức Anh
2021-10-01 11:32:44
using System;
namespace Ex1398
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter N:");
int n = int.Parse(Console.ReadLine());
int i = n - 1;
while (i >= 0)
{
int j = 0;
while (j <= i)
{
Console.Write("*");
j++;
}
Console.WriteLine("");
i--;
}
Console.ReadKey();
}
}
}
![Phạm Đăng Khoa [community,C2010L]](https://www.gravatar.com/avatar/c38babdc190b58e31608b8ddefc3ba1a.jpg?s=80&d=mm&r=g)
Phạm Đăng Khoa
2021-09-30 14:03:17
using System;
namespace Lesson01
{
class Program
{
static void Main(string[] args)
{
int n = 6;
int i = n - 1;
while (i >= 0)
{
int j = 0;
while (j <= i)
{
Console.Write("*");
j++;
}
Console.WriteLine("");
i--;
}
}
}
}
![Đỗ Minh Tâm [community,C2010G]](https://www.gravatar.com/avatar/b2f111c1b0e4273177f902fd0c0f11ae.jpg?s=80&d=mm&r=g)
Đỗ Minh Tâm
2021-09-28 09:22:45
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("nhap vao so n:");
int n = int.Parse(Console.ReadLine());
int i = n - 1;
while (i >= 0)
{
int j = 0;
while (j <= i)
{
Console.Write("*");
j++;
}
Console.WriteLine("");
i--;
}
}
}
}
![Kim Văn Thiết [community,AAHN-C2009G]](https://www.gravatar.com/avatar/a6fe3c0fba887fdd75f4bdc95b86b1f7.jpg?s=80&d=mm&r=g)
Kim Văn Thiết
2021-09-23 05:28:19
static void bai1()
{
Console.WriteLine("Enter N: ");
int N = int.Parse(Console.ReadLine());
int A = N;
for(int i = 0; i < N; i++)
{
int j = 0;
while ( j < A)
{
Console.Write('*');
j++;
}
A--;
Console.WriteLine();
}
}
![Hoàng Văn Huy [community,AAHN-C2009G]](https://www.gravatar.com/avatar/e18bc9a35ee76a52dd652e63b2bad8e2.jpg?s=80&d=mm&r=g)
Hoàng Văn Huy
2021-09-23 02:47:34
#Program.cs
using System;
namespace Core
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter a number: ");
int num = Console.Read();
for(int i = 0; i <= num; i++)
{
for(int j = 0; j <= i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
}
}
}
![Hoàng Thiện Thanh [community,AAHN-C2009G]](https://www.gravatar.com/avatar/58e377dde293f6da38c0b5168578557a.jpg?s=80&d=mm&r=g)
Hoàng Thiện Thanh
2021-09-22 02:05:45
#Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the number of max elements:");
int n = int.Parse(Console.ReadLine());
int i = n - 1;
while (i >= 0)
{
int j = 0;
while (j <= i)
{
Console.Write("*");
j++;
}
Console.WriteLine("");
i--;
}
}
}
}
![Nguyễn Việt Hoàng [community,AAHN-C2009G]](https://www.gravatar.com/avatar/bdbde8074d82148dcda6927ccb016466.jpg?s=80&d=mm&r=g)
Nguyễn Việt Hoàng
2021-09-21 17:27:39
#Program.cs
using System;
namespace Triagle
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter N :");
int n = int.Parse(Console.ReadLine());
for(int i = n - 1; i >= 0; i--)
{
for (int j = 0; j <= i; j++)
{
Console.Write("*");
}
Console.WriteLine("");
}
}
}
}
![vuong huu phu [T2008A]](https://www.gravatar.com/avatar/307a5cf29780afab49706dc8b15b86c6.jpg?s=80&d=mm&r=g)
vuong huu phu
2021-05-17 10:36:59
using System;
namespace insao
{
class Program
{
static void Main(string[] args)
{
int n;
Console.WriteLine("Nhap so pan tu");
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 Anh Vũ [T2008A]](https://www.gravatar.com/avatar/8863d24ed74b396082becbc4db8331fd.jpg?s=80&d=mm&r=g)
Nguyễn Anh Vũ
2021-05-17 10:14:02
using System;
using System.Collections.Generic;
using System.Text;
namespace TamGiac
{
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");
}
}
}
![Do Trung Duc [T2008A]](https://www.gravatar.com/avatar/2973ac07124f066b4605c535e8d39a99.jpg?s=80&d=mm&r=g)
Do Trung Duc
2021-05-17 08:33:04
using System;
using System.Collections.Generic;
namespace Inhinhsao
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("NHap N: ");
int N = Int32.Parse(Console.ReadLine());
List<string> str = new List<string>();
for(int i = 0; i < N; i++)
{
str.Add("*");
foreach(string s in str)
{
Console.Write("{0}", s);
}
Console.WriteLine("");
}
}
}
}