C++ reads continuous data and ends with a carriage return

Reference: click on the link

#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;
}

Guess you like

Origin blog.csdn.net/qq_31672701/article/details/108194697