namespace ProgrammingTesting
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter the input");
string input1 = Console.ReadLine();
if (input1 == "4")
{
Console.WriteLine("You are a winnere");
Console.ReadLine();
}
else if (input1.Length < 4)
{
Console.WriteLine("TOOOOO high");
}
else if (input1.Length > 4)
{
Console.WriteLine("TOOOO Low");
Console.ReadLine();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果我输入的数字小于4,为什么程序输出"太低".
我使用C++中的Microsoft Visual Studio 2012 Ultimate IDE构建了非常简单的win32控制台程序;
这是代码:
int _tmain(int argc, _TCHAR* argv[])
{
int i = 0;
i++;
return = 0
}
Run Code Online (Sandbox Code Playgroud)
通过代码逐行调试,我注意到了这一点:
在Debug x64模式下argc = 1,argv[0] = the program's path
在Release x64模式下argc = some random large number,argv[0] = some random path or simply 0x00000001
为什么是这样?
任何帮助,将不胜感激.
我可以使用 Console.Write 将这样的代码打印到文本文件中吗?
Console.Write(" Enter your ID: ");
int ID = int.Parse(Console.ReadLine());
Console.Write(" Enter your Name: ");
string Name = Console.ReadLine();
Console.WriteLine(" Thank you! your logged in as" +Name+ +ID);
Run Code Online (Sandbox Code Playgroud)
请帮忙!
提前致谢。
所以,有两个日期,我必须检查是否date1远离date2.最好的方法是什么?
int date1_day = 21, date1_month = 1, date1_year = 1990;
int date2_day = 19, date2_month = 5, date2_year = 1989;
if(???)
{
// date1 is further away
}
Run Code Online (Sandbox Code Playgroud)
几个小时我一直在努力争取这个.
我试图删除一个字符串的最后一部分,但失败了.这个字符串命名D:\software\VS2012\newtext.txt,我想修剪字符串的最后一部分,所以在这里newtext.txt.我应该得到D:\software\VS2012但是如何在c#中做到.当我尝试它时,删除所有带有'\'的字符串.这是我在c#中所做的
string str = @"D:\softwares\VS2012\newtext.txt";
str= str.Remove(str.IndexOf('\\'));
Console.WriteLine(str);
Run Code Online (Sandbox Code Playgroud) 我会试着解释一下我想做什么.我有程序(不起作用),它是从Windows中的CMD控制台调用的.我正在使用main函数的参数
int main(int argc, char *argv[])
Run Code Online (Sandbox Code Playgroud)
但在这种情况下我不能使用调试器来找到我做错了什么...我能以某种方式将char*argv []参数连接到代码中创建的表吗?例:
int main(int argc, char *argv[])
{
char tablica[] = { 'K','2','+','1','-','3','*','(','3','+','2',')','*','2' };
tablica = **argv; //// IDK HOW TO CONNECT THESE TWO
Run Code Online (Sandbox Code Playgroud) 我是 Visual Basic 的新手,需要帮助。
我以前使用过 python,您只需执行以下操作即可创建项目列表:
列表 = [项目 1,项目 2]
但我不知道如何在 Visual Basic 中做到这一点。
请有人帮我简单地创建一个列表,就像在 python 中一样,但在 Visual Basic 中?
我在控制台应用程序中使用 while 循环创建多个任务。
从数据库中选择和更新记录。
我的程序只会执行一次然后关闭窗口。
如何保持控制台窗口打开,并无限运行任务。
static void Main(string[] args)
{
Task.Run(async () => // <- marked async
{
while (true)
{
InsertProcess(GameList.RO1);
await Task.Delay(5000);
}
});
Task.Run(async () => // <- marked async
{
while (true)
{
InsertProcess(GameList.ROS);
await Task.Delay(5000);
}
});
}
public static void InsertProcess(Game game)
{
using (SqlConnection conn = new SqlConnection(RO1DBConn))
{
// ... query database
}
}
Run Code Online (Sandbox Code Playgroud) 使用文本文件作为数据库。你如何让你的程序知道它是否是第一次运行?如果它是第一次运行,那么应用程序需要创建存储实体的表。如果不是第一次运行,那么如果文本文件中存储了任何数据,它应该使用用户数据运行应用程序。
我在寻找递归函数示例时使用 grpper 找到了这个代码片段。我理解递归部分,函数如何调用自身 - 1 直到它到达基本情况,但是,我不理解 else 中的最后一行。只是想弄清楚最后一行如何使数字返回到起始值。代码中没有任何内容将其设置为 +1,而且,随着它返回,它是调用函数本身还是只是我不知道的规则?只是想把我的脑袋围绕在这里的逻辑。
void PrintTest(int test)
{
if (test < 1)
{
return; // Exit condition, known as "base case"
}
else
{
cout << test << " ";
PrintTest(test-1);
cout << test << " ";
}
}
int main()
{
int a;
cout << "Enter a number prefarably between 2 and 9: ";
cin >> a;
PrintTest(a);
Run Code Online (Sandbox Code Playgroud)
我知道这可能是一个愚蠢的问题,但只是想了解为什么“cout << test <<”“;” 增加数字备份就是这样。
c++ ×5
c# ×4
.net-4.0 ×1
comparison ×1
console ×1
if-statement ×1
string ×1
vb.net ×1
winapi ×1