gpt4 book ai didi

c# - C#代码可在Visual Studio 2019中使用,但不能在在线编译器中使用

转载 作者:行者123 更新时间:2023-12-02 10:53:31 25 4
gpt4 key购买 nike

我正在做在线测试。该代码在我的Visual Studio 2019上可以完美运行,但在我提交它时却不能。甚至其他在线编译器也会引发许多编译错误。在线测试环境设置为:Mono C#的DMCS版本,带有标志的编译器版本4.6.2.0:-optimize + -r:System.Numerics {files}。

我试图将.NET目标框架更改为4,但是在计算机上没有出现任何错误。如何将Visual Studio配置为与上述相同的设置?

enter image description here

使用系统;
使用System.Collections.Generic;

命名空间capgemini_kattis
{
类(class)计划
{
静态void Main(string [] args)
{

        /*
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Task 2
*/
bool isNumberOfCommandsRead = false;
List<string> answer = new List<string>();
string input = "????????????????????????????????";
Char[] charArray = input.ToCharArray();
int numberOfCommands = 0;
string line;

void CLEAR(int i)
{
charArray[i] = '0';
}
void SET(int i)
{
charArray[i] = '1';
}
void OR(int i, int j)
{
if (charArray[i] == '1' || charArray[j] == '1')
{
charArray[i] = '1';
}
else if (charArray[i] == '0' && charArray[j] == '0')
{
charArray[i] = '0';
}
else
{
charArray[i] = '?';
}
}
void AND(int i, int j)
{
if (charArray[i] == '1' && charArray[j] == '1')
{
charArray[i] = '1';
}
else if (charArray[i] == '0' || charArray[j] == '0')
{
charArray[i] = '0';
}
else
{
charArray[i] = '?';
}
}

while ((line = Console.ReadLine()) != null)
{
if (!isNumberOfCommandsRead)
{
numberOfCommands = Convert.ToInt32(line.Trim());
isNumberOfCommandsRead = true;
if (numberOfCommands == 0)
{
break;
}
}


else
{
string[] split = line.Split(new char[] { ' ' }, StringSplitOptions.None);

switch (split[0].Trim().ToUpper())
{
case "CLEAR":
CLEAR(Convert.ToInt32(split[1].Trim()));
numberOfCommands--;
break;

case "SET":
SET(Convert.ToInt32(split[1].Trim()));
numberOfCommands--;
break;

case "OR":
OR(Convert.ToInt32(split[1].Trim()), Convert.ToInt32(split[2].Trim()));
numberOfCommands--;
break;

case "AND":
AND(Convert.ToInt32(split[1].Trim()), Convert.ToInt32(split[2].Trim()));
numberOfCommands--;
break;
}


if (numberOfCommands == 0)
{
Array.Reverse(charArray);
string sectionResult = "";
for (int i = 0; i < (new string(charArray)).Length; i++)
{
sectionResult += charArray[i].ToString();
charArray[i] = '?';
}
answer.Add(sectionResult);
sectionResult = null;
isNumberOfCommandsRead = false;
}
}
}

foreach (string s in answer)
{
Console.WriteLine(s);
}
Console.ReadLine();
}
}

}

最佳答案

我发现Repl.it正在Mono C#中编译,版本为4.6.2.0。它有助于发现问题并解决。

关于c# - C#代码可在Visual Studio 2019中使用,但不能在在线编译器中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55071880/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com