C++如何输入数组

如题,我定义了一个数组ARRAY[20],其中数组的20个元素由键盘输入,cin>>ARRAY[20];是错误的,请问应该怎么输入呢?

第1个回答  2010-04-26
#include<iostream.h>

void main()
{
int ARRAY[20];
for (int k=0; k<=19;k++)
{
cin>>ARRAY[k];
}
}
第2个回答  2020-06-14
Int ARRAY[20];
for(int n=0,n<20,n++)
Cin>>ARRAY[n];
//输入的数组下标应该比数组长度20小
第3个回答  2020-06-15
#include<iostream>
using
namespace
std;
long
sa[10];
int
main()
{
freopen("in.txt","w",stdout);
for
(long
a=0;a<10;++a)
{
scanf("%d",&sa[a]);
printf("%d
",sa[a]);
}
freopen("out.txt","w",stdout);
for
(long
a=9;a>=0;--a)
printf("%d
",sa[a]);
}
第4个回答  2019-07-04
#include<iostream>
#include<string>
using namespace std;
int main() {
string a;
cin >> a;
return 0;
}
第5个回答  2010-04-26
用for循环输入啊

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网