Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在HackerAth上使用C#时出现内存错误NZEC_C# - Fatal编程技术网

在HackerAth上使用C#时出现内存错误NZEC

在HackerAth上使用C#时出现内存错误NZEC,c#,C#,我正在解决一个问题。测试用例成功通过,但其余的用例显示NZEC错误。我知道NZEC代表非零出口代码,但我不知道为什么会发生这种情况 任何关于为什么会发生这种情况以及如何优化代码(最好不改变逻辑)的见解都会有所帮助 using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void Main(String[] args) {

我正在解决一个问题。测试用例成功通过,但其余的用例显示NZEC错误。我知道NZEC代表非零出口代码,但我不知道为什么会发生这种情况

任何关于为什么会发生这种情况以及如何优化代码(最好不改变逻辑)的见解都会有所帮助

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class Solution
{
    static void Main(String[] args)
    {
        int t = int.Parse(Console.ReadLine());
        int[] arr = new int[3];
        for(int m = 0; m < t; m++)
        {
            arr[m] = int.Parse(Console.ReadLine());
        }
        for (int n = 0; n < t; n++)
        {
            int i, j;
            for (i = 0; i < arr[n]; i++)
            {
                for (j = 0; j < 2 * arr[n]; j++)
                {
                    if (j <= i || j >= 2 * arr[n] - 1 - i)
                    {
                        Console.Write("*");
                    }
                    else
                    {
                        Console.Write("#");
                    }
                }
                Console.WriteLine("\n");
            }
            Console.WriteLine("\n");
        }

    }
}
使用系统;
使用System.Collections.Generic;
使用System.IO;
使用System.Linq;
类解决方案
{
静态void Main(字符串[]参数)
{
int t=int.Parse(Console.ReadLine());
int[]arr=新的int[3];
对于(int m=0;m
一旦确定了NZEC所代表的含义,那么解决方案就会变得明显。
int[]arr=new int[3]-如果t>3怎么办?我也猜您的输出是错误的:
Console.WriteLine(“\n”)
将编写两个换行符,而不是一个,我认为每个换行符只需要一个。在最终的模式之后可能没有一条尾随线,但您可能会侥幸逃脱。@Rup谢谢。显然,保持新的int[3]是个问题。我应该在那里有新的int[t]。