我试图写一个C++代码,得到的输入形式的用户,并存储在数组中,然后打印背面的元件随机地在4radomly从阵列上使用C++
下面组的每一个循环中选择n个元素是我的代码。
#include<iostream>
using namespace std;
int main(){
int i; int arr[5];
cout << "Enter some numbers" << endl;
for(i=0; i<5; i++){
cin >> arr[i];
}
for(int k=0; k<5; k++){
cout << arr[k];
cout << " ";
}
cout << " " << endl;
}
池获得4张随机数1.你的问题是什么? 2.你在'for'循环中有*未定义的行为(你正在访问数组越界) – UnholySheep
你为什么用C标记你的问题? – pmg
@pmg it's C++ not c。 –