方法一
#includestring st; getline(cin, st); stringstream qwe(st); int a[3]; int s = 0; while (qwe) qwe >> a[s++];
注解:
getline(cin,string)是从cin中把一行赋给string
stringstream qwe(st); 是指把st串中的内容赋给qwe流,正好把其中的 ’ ’ 变成数字的间隔
顺带一提
这是数组用的getline
char a[]; cin.getline(a,size)
还有string a 转char[] b是
strcpy(b, a.c_str());
方法二
while (getchar() != 'n') cin >> a[i++];
通过读回车来判定
方法三
while (scanf("%d", &a) != EOF)
cout << a << endl;
这种方法在调试时可以成功,但是自己输入要输ctrl+z三次,测试起来比较麻烦
还有一种cin版的
while (cin >> a) cout << a << endl;
不过都仅能读一行



