C++读取连续数据,以回车结束

参考:点击链接

#include<bits/stdc++.h>

using namespace std;

int main(){
    
    
	int a;
	vector<int> nums;
	while(cin >> a){
    
    
		nums.push_back(a);
		char c = cin.get();
		if(c == '\n')
			break;
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_31672701/article/details/108194697