没有获得钻石图案所需的镜像? [英] Not getting desired mirror image in diamond pattern?

查看:58
本文介绍了没有获得钻石图案所需的镜像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个显示钻石图案的程序。钻石的行数将等于用户输入的输入值。这就是我所做的。但是钻石的下半部分不打印上部的镜像?

这是我的程序:

 使用系统; 
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Text;
使用 System.Threading.Tasks;

命名空间 diamonddemo
{
class 计划
{
静态 void Main( string [] args)
{
Console.WriteLine( 显示程序模式*。);
Console.Write( 输入*:)的最大数量;
int n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine( \ nHere是Diamond of Stars \ n) ;
for int i = 0 ; i < n; i = i + 2){
for (< span class =code-keyword> int j = 0 ; j< = i; j ++)
Console.Write( *);
Console.WriteLine();
}
for int i = n-1; i> = < span class =code-digit> 1 ; i = i-2)
{
for int j = 0 ; j<(ni); j ++)
Console.Write( *);
Console.WriteLine();
}
Console.ReadLine();
}
}
}

解决方案

仅回答从未答复列表中删除:由OP解决

I am making a program to display diamond pattern. Number of rows of diamond would be equal to the input value entered by user. That is what i have done. But lower part of diamond is not printing mirror image of upper part?
Here is my program:

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

namespace diamonddemo
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Program for displaying pattern of *.");
            Console.Write("Enter the maximum number of *: ");
            int n = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("\nHere is the Diamond of Stars\n");
                for (int i = 0; i < n; i= i+2) {
                for (int j = 0; j<=i; j++)
                Console.Write("*");         
                Console.WriteLine();
               }
               for (int i = n-1; i>=1; i=i-2)
               {
                   for (int j = 0; j<(n-i); j++)
                       Console.Write("*");
                   Console.WriteLine();
               }
          Console.ReadLine();
      }
    }
}

解决方案

Answered only to remove from unanswered list: solved by OP.


这篇关于没有获得钻石图案所需的镜像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆