在运行时无法输入
Not being able to enter input during runtime
当我使用输入编译代码时,它工作正常。但是当我想用用户输入运行它时,它只是不接受输入。它不会给出任何错误。
// kefaa and first steps
// 2 2 1 3 4 1
#include <bits/stdc++.h>
using namespace std;
int main(){
int n, a[n], counter=0, maxIncr=0;
cin >> n;
cin.sync();
for(int i = 0; i < n; ++i){
cin >> a[i];
}
for(int i=0; i < n-1; ++i){
if (a[i] <= a[i+1]){
counter += 1;
if(maxIncr<counter)
maxIncr=counter;
}else{
counter=1;
}
}
cout << maxIncr;
return 0;
}
首先,请阅读有关您的包含以及为什么我们不像这样包含的内容。
其次,如果您希望程序运行:
int n;
cin >> n;
int a[n], counter=0, maxIncr=0;
你有什么样子@UnholySheep写给你的,当 n 尚未赋值时,你初始化 a[n]。
相关文章:
- 我可以根据用户输入在运行时生成"循环"吗?
- 在运行时为动态分配的内存输入值
- 在 Linux 上C++:在作为 systemd 服务运行时侦听键盘输入
- 在运行时无法输入
- 将输入输入到 c++ 数组时出现运行时错误
- 如何根据运行时输入实例化 c++ 模板
- 如何处理在 bash 文件中获取运行时输入的 c++ 程序
- 根据用户的输入在运行时创建对象
- 提升反序列化问题:运行时输入流错误 (c++)
- 我想进行运行时输入而不是命令行参数,如何做
- 运行时用户输入解析
- 基于用户输入的运行时函数规范
- 两个输入函数的 T(n) 运行时
- 为什么只有当输入为5时才会出现运行时错误
- 在C++程序运行时输入输入值 (./filename.out)
- 如何在 C++ 中运行时输入指数
- 为什么在为数组输入并输入合并排序函数后出现运行时错误
- C++我在运行时创建一个输出文件,如何再次读取此输出文件作为输入
- 大型输入C++上的运行时错误
- 我的程序在运行时不会打印任何内容,输入几个随机数后它会工作(有很多错误)