📜  向量在换行处停止 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:57.464000             🧑  作者: Mango

代码示例1
// read N1 & N2 using cin
int N1, N2;
cin >> N1;
cin >> N2;

// skip the new line which is after N2 (i.e; 2 value in 1st line)
cin.ignore(numeric_limits::max(), '\n');

// now read 3 4 5 elements
int ele;
// 2nd EOF condition may required,
//    depending on if you dont have last new-line, and it is end of file.
while ((cin_.peek() != '\n') && (cin_.peek() != EOF)) {
  cin >> ele;
  // do something with ele
}