C#输出心形图案(一)

来源:互联网 发布:cdr软件图标 编辑:程序博客网 时间:2024/05/14 00:29
用C#语言简单的在控制台输出一个心形。。使用逻辑语句
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication2{    class Program    {       static void Main(string[] args)       {           float y,x, z, f;           for (y =1.5f; y > -1.5f; y -= 0.1f)           {              for (x = -1.5f; x < 1.5f;x += 0.05f)              {                 z = x * x + y * y - 1;                 f = z * z * z - x * x * y * y * y;                 Console.Write(f <= 0.0f ? ".:-=+*#%@"[(int)(f* -8.0f)] : ' ');              }              Console.WriteLine();           }          Console.ReadLine();       }    }}
注:出处为蓝桥杯练习题


运行结果:

C#输出心形图案(一)

原创粉丝点击