如何修复失败的构建,没有错误
How to fix failed build with no errors
我真的是编程新手。我尝试制作某种排序应用程序,通过交换数组中的值对数组进行排序。但是当我尝试构建它时,它只是说构建失败。Visual Studio没有给出错误,所以我有点卡住了。你能帮帮我吗?
我尝试增加数组大小,并确保没有任何循环向数组写入比可能更多的整数。
#include <iostream>
using namespace std;
int arr[10];
bool sorted = false;
int compare(int x, int y);
int cycle;
int compres;
int slot;
int main()
{
for (int c = 0; c < 5; c++)
{
cin >> arr[c];
}
while (cycle <= 5)
{
compres = compare(cycle, cycle + 1);
if (compres == 1)
{
slot = arr[cycle];
arr[cycle] = arr[cycle + 1];
arr[cycle + 1] = slot;
cout << arr[cycle] << " and " << arr[cycle + 1] << "swapped" << endl;
}
else if (compres == 0)
{
cout << arr[cycle] << " is equal to " << arr[cycle + 1] << endl;
}
else if (compres == -1)
{
cout << arr[cycle] << " and " << arr[cycle + 1] << "are already sorted" << endl;
}
else
{
cout << "(!) Compare issue." << endl;
}
cycle++;
}
for (int i = 0; i < 5; i++)
{
cout << arr[i];
}
}
int compare(int x, int y)
{
if (x > y) { return 1; }
if (x == y) { return 0; }
if (x < y) { return -1; }
}
输出日志:https://i.stack.imgur.com/6mw5d.png
我认为在创建项目时出了点问题......我做了一个新的并复制粘贴了代码,它有效。感谢您的回答!
相关文章:
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- Arch Linux.AUR 包 mysql 不能用 makepkg 构建.错误:构建 () 中出现故障
- 我的代码中有错误,未声明的标识符
- 调试模板时出现问题.专门针对 Linux GCC 7、GCC 6、GCC 5、GCC 4.9 错误构建失败:模板参数 1
- 是否有可能构建面向Linux和Windows的.Net Core C++ / CLI应用程序?
- C++ LeetCode #377 的 DP 解决方案中,此代码是否有错误?
- 试图建立银行管理系统,但有错误
- 我试图创建临时对象的方式有错误吗
- 我的随机生成器是否不工作,或者我决定人/骨架是否击中对手的方式是否有错误
- 我在OpenCV中有错误的"approxPolyDP(ROI_Vertices, ROI_Poly, 1.0, true)"
- 我在这个 C++ 代码上有错误吗?
- 是视觉C++优化器错误还是我的代码中有错误?
- 为什么一个简单的C++程序会有错误的结果?是 #define 引起的吗?
- 对此有错误
- C :数据文件有错误:预期的无限制ID
- MINGW的错误构建提升
- 一个带有参数的程序,为什么此程序有错误的答案
- 仅使用boost.datetime在Windows上有错误
- 使用向量循环时,是否有错误
- 从Canfestival错误构建CanOpen的示例