test1:
Enter multiple data
#include <iostream> #include <vector> using namespace std; int main() { int num
; while (cin >> num) { vector<int> ivec; for (int i = 0; i<num; ++i) { int temp;
cin>> temp; ivec.push_back(temp); } for (int i = 0; i < ivec.size(); ++i) {
cout<< ivec[i] << " "; } cout << endl; } return 0; }
// Use spaces and newlines for cin It's all endings
input :( End with line feed )
4
1 2 3 4( End with a space )
output :
1 2 3 4( The final effect )
..............
input :
4( End with line feed )
1( End with line feed )
2
3
4
output :
1 2 3 4
..............
input :
4 1 2 3 4( End with a space )
output :
1 2 3 4
*/
test 2 Two input variables
#include <iostream> #include <vector> using namespace std; int main() { int num
, n; while (cin >> num >> n) { cout << num << " " << n << endl; } return 0; }
/*
input :
11 22
output :
11 22
..........
input :
11 22 33 44
output :
11 22
33 44
*/
Technology