#include <iostream>
#include <vector>
using namespace std;
int main(){
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
vector<vector<int>> a;
string s;
while(getline(cin, s)){
string cur = "";
vector<int> t;
for(int i = 0; i < s.length(); i++){
if(s[i] == ' '){
t.push_back(stoi(cur));
cur.clear();
}
else{
cur += s[i];
if(!cur.empty())
a.push_back(t);
for(auto &i : a){
for(auto &j : i)
cout << j << " ";
cout << "\n";
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
#include <vector>
using namespace std;
int main(){
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
vector<vector<int>> a;
string s;
while(getline(cin, s)){
string cur = "";
vector<int> t;
for(int i = 0; i < s.length(); i++){
if(s[i] == ' '){
t.push_back(stoi(cur));
cur.clear();
}
else{
cur += s[i];
}
}
if(!cur.empty())
t.push_back(stoi(cur));
a.push_back(t);
}
for(auto &i : a){
for(auto &j : i)
cout << j << " ";
cout << "\n";
}
}