aboutsummaryrefslogtreecommitdiff
path: root/challenge-204/paulo-custodio/cpp/ch-2.cpp
diff options
context:
space:
mode:
authorPaulo Custodio <pauloscustodio@gmail.com>2023-03-02 21:32:53 +0000
committerPaulo Custodio <pauloscustodio@gmail.com>2023-03-02 21:32:53 +0000
commit38d82321ddc0f1b10d9c8e97ebbcbfbfa5d5a8d9 (patch)
tree7b471f58e0e3091231d0c82cb7523dffb0a01c33 /challenge-204/paulo-custodio/cpp/ch-2.cpp
parent5c33806bdd7d70d9179fec0594ffec63afa23ab2 (diff)
downloadperlweeklychallenge-club-38d82321ddc0f1b10d9c8e97ebbcbfbfa5d5a8d9.tar.gz
perlweeklychallenge-club-38d82321ddc0f1b10d9c8e97ebbcbfbfa5d5a8d9.tar.bz2
perlweeklychallenge-club-38d82321ddc0f1b10d9c8e97ebbcbfbfa5d5a8d9.zip
whitespace
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();
}