c# - 我怎样才能修复这个在运行时什么都不做的代码?
问题描述
好吧,我试图用一些 if 语句在 c# 中做一个简单的代码,但由于某种原因,我不理解代码编译但不让我与之交互。控制台窗口保持黑色,当我按下某个键时没有任何反应。它应该显示结果的值(一两个取决于情况)。编码:
int result1;
int result2;
int delta = (b * b) - 4 * a * b;
//Declaration of the variables results and delta, the ones that will be used in the following block
if ((a != 0) && (b != 0) && (c != 0))
{
if (delta == 0)
{
result1 = (-b) / (2 * a);
Console.WriteLine(result1);
}
else if (delta > 0)
{
result1 = (-b + Root(delta)) / (2 * a);
result2 = (-b - Root(delta)) / (2 * a);
Console.WriteLine(result1);
Console.WriteLine(result2);
}
else
{
Console.WriteLine("Sem resultado: delta menor que zero.");
}
}
//In this if clause the code will verify the use of Bhaskara and the value of delta. Then execute the right count.
上面的“root”方法是这样的:
static int Root (int radi)
{
int rootTester = 0;
int result;
for (; ;)
{
rootTester++;
if(rootTester * rootTester != radi)
{
continue;
}
else
{
break;
}
}
result = rootTester;
return result;
//Here the compiler will try to multiplie a number for itself until this number will get equal the value of the radial
}
变量“a”、“b”和“c”的值分别为 1、-20 和 51。我试图更改 place 的 delta 声明,但没有成功。我怎么解决这个问题?(对不起,如果我用英语说错了)
解决方案
你忘记了 Console.ReadLine();
推荐阅读
- visual-studio-code - 如何安装两个 VS Code?
- python - python 在聊天程序中,我必须按回车才能看到第二个人的消息,如何实时做到这一点?
- python - For循环不断让jupyter卡住
- utf-8 - 以前在 CodeIgniter 4 中将 URL 编码为 UTF-8
- php - 合并重复的键值并在动态多维数组中求和
- android - 如何在Android的xml布局中获取对项目(imageView)的引用
- c# - 如何在 Microsoft Store 应用程序中嵌入字体
- c++ - 如何知道有多少设备远程连接到sqlserver
- postgresql - TypeORM 查询生成器查找 id 等于 PostgreSQL UUID 的位置
- php - 与预订数量最近的日期