C#打印出正等腰三角形實(shí)例代碼
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 打印正三角
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("請輸入要打印的行數(shù):");
int n=Convert.ToInt32(Console.ReadLine());
Console.Clear(); //清除以上顯示的內(nèi)容
//這層循環(huán)控制打印的行數(shù)
for (int i = 1; i <= n; i++)
{
//這層循環(huán)控制每行前面打印的空格數(shù)
for (int k = 1; k <= n - i; k++)
{
Console.Write(" ");
}
//這層循環(huán)控制每行前面打印*的個(gè)數(shù)
for (int j = 1; j <= 2 * i - 1; j++)
{
Console.Write("*");
}
//每打印完一行換一下行
Console.Write("\n");
}
Console.ReadKey();
}
}
}
運(yùn)行效果:
- C#打印類PrintDocument、PrintDialog、PrintPreviewDialog使用示例
- C#實(shí)現(xiàn)打印與打印預(yù)覽功能的思路及代碼
- C#中通過API實(shí)現(xiàn)的打印類 實(shí)例代碼
- C# 獲取打印機(jī)當(dāng)前狀態(tài)的方法
- C# 實(shí)現(xiàn)簡單打印的實(shí)例代碼
- C#實(shí)現(xiàn)的ZPL條碼打印類完整實(shí)例
- C#完成word文檔打印的方法
- C#條碼生成及打印實(shí)例代碼
- C#打印繪圖的實(shí)現(xiàn)方法
- C#利用PrintDocument定制打印單據(jù)的小例子
相關(guān)文章
C#找不到類型名"SqlConnection"的有效解決方法
最近在使用c#鏈接SqlServer的時(shí)候遇到了錯(cuò)誤,通過查找相關(guān)資料終于解決了,所以下面這篇文章主要給大家介紹了關(guān)于C#找不到類型名"SqlConnection"的有效解決方法,需要的朋友可以參考下2023-02-02將excel數(shù)據(jù)轉(zhuǎn)換成dataset示例
這篇文章主要介紹了不借助第三方插件的情況下將Excel中的數(shù)據(jù)轉(zhuǎn)換成DataSet的方法,需要的朋友可以參考下2014-02-02