i don't know how take input like the following code
1 4 3 2 9 7 18 22 0
2 4 8 10 0
7 5 11 13 1 3 0
-1
each line finished when take zero
and finished taking input when take -1
Do this code is right for this task ?
int n;
vector<vector<int> >v;
while(cin>>n && n!=-1){
vector<int>temp;
if(n!=0){
temp.push_back(n);
}
v.push_back(temp);
}
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
char string[128];
do {
cin.getline(string, sizeof(string), '0');
cout << endl;
for (int i = 0; i < sizeof(string); i++){
if (string[i] == '-1') {
getch();
return 0;
}
}
} while (true);
cout << endl;
getch();
return 0;
}