为什么我的程序不能作为exe文件工作?
Why does my program not work as an exe file?
大家好,我是编程新手。我刚刚开始学习c++,为大学二年级做准备。所以我跟随了一些教程,完成了这个"计算器"程序。我使用CodeBlocks作为我的IDE。它会自动创建一个exe文件,您可以打开并运行该程序。在IDE中运行。
然而,运行exe程序,它自动关闭后,我输入我的第二个号码。而不是显示两个数字的和差或乘积,它只是关闭。
我的代码
#include <iostream>
using namespace std;
int main()
{
string input;
cout << "Addition(A), Subtraction(S), Multiplication(M), or Division(D)"<<endl;
cin >>input;
int a;
int b;
if(input == "Addition")
{
cout << "Enter Your First Numbern";
cin>>a;
cout << "Enter Your Second Numbern";
cin>>b;
int sum = a+b;
cout << "Here is the sum of the two numbers:" <<sum;
}
else if(input == "Subtraction"){
cout << "Enter Your First Numbern";
cin>>a;
cout << "Enter Your Second Numbern";
cin>>b;
int sub = a-b;
cout<< "Here is the subtraction of the two numbers:" << sub;
}
else if(input == "Multiplication")
{
cout << "Enter Your First Numbern";
cin>>a;
cout << "Enter Your Second Numbern";
cin>>b;
int product = a*b;
cout<< "Here is the product of the two numbers:" << product;
}
else if(input == "Division")
{
cout<<"No Division Please.";
}
return 0;
}
输入第二个数字后,程序将执行其任务并打印结果。然后它就完成了,所以它退出并且它的窗口关闭。
在现有的控制台窗口中启动它,以便在它终止后查看程序的输出。
相关文章:
- 终端不会为C++文件创建.exe文件吗
- 从 exe 文件 (Visual Studio ) 启动时调试断言失败
- 如何在Visual Studio Code中重命名我的a.exe文件?
- 在VS Code中编译C / C ++时如何禁用自动创建EXE文件?
- 来自Visual Studio中控制台项目的exe文件?
- 在安卓应用程序中使用.exe文件
- 更新到 2020 年 5 月版本后,无法在 Visual Studio 2019 中创建.exe文件
- 有没有一种方法可以将数据从javascript发送到exe文件
- C++程序编译器在使用g++命令编译后自动运行exe文件
- 在位置上运行具有依赖项的.exe文件
- 是否可以将 EXE 文件作为 lib 文件链接到另一个项目?
- Qt .exe文件错误
- 如何检查 win32 exe 文件是否已运行?(使用 win32 API 代码)
- 获取 exe 文件夹路径的最佳方法?
- 从 Qt(release) 生成的文件执行.EXE文件时出错
- 如何将本地文件嵌入从C 项目生成的EXE文件中
- 在不同的计算机上运行.exe文件.(视觉工作室)
- 如何循环访问在 cmd 中获取参数的 exe 文件
- 将 14 GB 数据附加到 EXE 文件的末尾
- 将清单嵌入到 exe 文件