63 200
Assignments Done
99,3%
Successfully Done
In July 2018

Answer to Question #17085 in C++ for sahar

Question #17085
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);
}
Expert's answer
#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;

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions