aboutsummaryrefslogtreecommitdiff
path: root/challenge-204/paulo-custodio/cpp/ch-2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-204/paulo-custodio/cpp/ch-2.cpp')
-rw-r--r--challenge-204/paulo-custodio/cpp/ch-2.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/challenge-204/paulo-custodio/cpp/ch-2.cpp b/challenge-204/paulo-custodio/cpp/ch-2.cpp
index 331715e1c7..0904357163 100644
--- a/challenge-204/paulo-custodio/cpp/ch-2.cpp
+++ b/challenge-204/paulo-custodio/cpp/ch-2.cpp
@@ -54,41 +54,41 @@ std::vector<int> data;
size_t rows = 0, cols = 0;
void parse_data() {
- std::string line;
- while (std::getline(std::cin, line)) {
- if (line.find('[') != std::string::npos) {
- size_t pos;
- while ((pos = line.find('[')) != std::string::npos) line[pos] = ' ';
- while ((pos = line.find(']')) != std::string::npos) line[pos] = ' ';
- std::istringstream iss{ line };
- int n;
- while (iss >> n) {
- data.push_back(n);
- }
- }
- else {
- std::istringstream iss{ line };
- iss >> rows >> cols;
- break;
- }
- }
+ std::string line;
+ while (std::getline(std::cin, line)) {
+ if (line.find('[') != std::string::npos) {
+ size_t pos;
+ while ((pos = line.find('[')) != std::string::npos) line[pos] = ' ';
+ while ((pos = line.find(']')) != std::string::npos) line[pos] = ' ';
+ std::istringstream iss{ line };
+ int n;
+ while (iss >> n) {
+ data.push_back(n);
+ }
+ }
+ else {
+ std::istringstream iss{ line };
+ iss >> rows >> cols;
+ break;
+ }
+ }
}
void output_data() {
- if (data.size() != rows*cols)
- std::cout << "0" << std::endl;
- else {
- for (int i = 0; i < rows; i++) {
- std::cout << "[ ";
- for (int j = 0; j < cols; j++) {
- std::cout << data[i*cols+j] << " ";
- }
- std::cout << "]" << std::endl;
- }
- }
+ if (data.size() != rows*cols)
+ std::cout << "0" << std::endl;
+ else {
+ for (int i = 0; i < rows; i++) {
+ std::cout << "[ ";
+ for (int j = 0; j < cols; j++) {
+ std::cout << data[i*cols+j] << " ";
+ }
+ std::cout << "]" << std::endl;
+ }
+ }
}
int main() {
- parse_data();
- output_data();
+ parse_data();
+ output_data();
}