打印陵形 算法
来源:互联网 发布:中国大数据 编辑:程序博客网 时间:2024/04/30 05:52
在业余的时候,用c#重新玩起了算法,写了一个简单的打印菱形的算法,与大家一起分享.
/***********************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.Write("请输入陵形长度(偶数字自动加1):");
int number = Convert.ToInt32(Console.ReadLine());
if (number % 2 == 0)
{
number += 1;
}
int counts = number / 2;
int nullCount = 0;
int starCount = number;
string sign = "*";
int perNull = 5;
for (int i = 0; i < number; i++)
{
string nullChar = null;
string star = null;
nullCount = counts - i;
if (nullCount < 0)
{ nullCount = nullCount * -1; }
for (int j = 0; j < nullCount + perNull; j++)
{ nullChar += " "; }
starCount = number - nullCount * 2;
for (int j = 0; j < starCount; j++)
{ star += sign; }
Console.WriteLine(nullChar + star);
}
Console.Read();
}
}
}
/***********************************************************************/
- 打印陵形 算法
- 顺时针打印矩阵[算法]
- 循环打印算法
- 算法一一 打印几何图形
- 算法系列--打印九九乘法表
- 算法矩阵打印2
- 打印九九乘法表算法-java
- 算法 打印全排列
- 打印菱形算法
- 算法--打印Ascii码
- java 打印菱形算法
- 倒序打印双链表算法
- 打印九九乘法表算法-java
- 二维数组螺旋式打印算法
- EAN-13条形码打印算法
- 打印质数的各种算法
- 打印素数的各种算法
- 【算法设计】打印螺旋数组
- DMA基本原理 结构与应用
- FreeMarker基于view层的开发
- 今天开始在此写博客了....
- 面试70问经典回答
- Java中的封装之我见
- 打印陵形 算法
- BIND9 + MySQL (MySQL BIND SDB Driver)
- 理论结合应用,帮你看懂正则表达式(转帖摘要)
- Ping-Microsoft Windows CE 3.0
- C语言数学函数
- 过新真三蓝宝石地图-MH命令工具
- Ping-Microsoft Windows XP Professional
- TCP acceleration
- 验证数字的正则表达式集