如何修复失败的构建,没有错误

How to fix failed build with no errors

本文关键字:有错误 构建 何修复 失败      更新时间:2023-10-16

我真的是编程新手。我尝试制作某种排序应用程序,通过交换数组中的值对数组进行排序。但是当我尝试构建它时,它只是说构建失败。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

我认为在创建项目时出了点问题......我做了一个新的并复制粘贴了代码,它有效。感谢您的回答!