系统( "pause" ) 不工作,任何人都可以看到我缺少什么吗?
system("pause") not working, can anyone see what I'm missing?
我的程序有错误,不让我编译。唯一的错误从系统("暂停")开始,但我不明白为什么我有错误,因为我和我一直做程序一样。任何人都可以看到可能的问题是什么吗?代码如下:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
//Declarations
int SIZE = 10;
int NUMBERS[10];
int i;
int j;
int temp;
for (int i = 0; i < SIZE; i++)
{
cout << "Please enter a number: " << endl;
cin >> NUMBERS[i];
}
for (int i = 0; i < SIZE; i++)
{
for (int j = 0; j < SIZE; j++)
{
if (NUMBERS[j] > NUMBERS[j+1])
{
temp = NUMBERS[j];
NUMBERS[j] = NUMBERS[j+1];
NUMBERS[j+1] = temp;
}
}
}
cout << "Sorted List" << endl;
cout << "===========" << endl;
for (int i = 0; i < SIZE; i++)
cout << "Number " << i + 1 << ": " << NUMBERS[i] << endl;
}
system("pause");
return 0;
}
for (int i = 0; i < SIZE; i++) {
// ^^^ add this missing bracket
cout << "Number " << i + 1 << ": " << NUMBERS[i] << endl;
}
^^^ // closing bracket, but has no opening match
当然,在这种情况下,您可以跳过大括号(因为正文只有一行),所以这也是解决方案:
for (int i = 0; i < SIZE; i++)
cout << "Number " << i + 1 << ": " << NUMBERS[i] << endl;
相关文章:
- 为不同配置设置MSVC_RUNTIME_LIBRARY的正确方法是什么
- 警告处理为错误这里有什么问题
- 什么时候调用组成单元对象的析构函数
- #定义c-预处理器常量..我做错了什么
- 努力将整数转换为链表。不知道我在这里做错了什么
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 什么时候在C++中返回常量引用是个好主意
- 当在同一名称空间中有两个具有相同签名的函数时,会发生什么
- C++避免重复声明的语法是什么
- c++库的公共头文件中应该包含什么
- 问题:什么是QAbstractItemView::NoEditTriggers的反面
- 有什么方法可以遍历结构吗
- 当类在C++中定义时,有什么方法可以"register"类吗?
- ifstream什么都没读
- 任何人都可以告诉我我的 C++ 代码出了什么问题?
- 任何人都解释下面的代码,它的输出是什么?
- Deque的解释是什么,任何人都可以帮助我
- 什么是C++中的容器类,任何人都可以举个好例子
- 任何人都可以解释一下这个C++代码在做什么
- 系统( "pause" ) 不工作,任何人都可以看到我缺少什么吗?