aboutsummaryrefslogtreecommitdiff
path: root/challenge-096/paulo-custodio/cpp/ch-1.cpp
diff options
context:
space:
mode:
authorPaulo Custodio <pauloscustodio@gmail.com>2021-01-25 20:07:40 +0000
committerPaulo Custodio <pauloscustodio@gmail.com>2021-01-26 00:06:54 +0000
commit3fa58628535d4041c7cc648c005080ca88f18c18 (patch)
tree336fe3cc14f518f05e871ab974cc86a09a2fd8f6 /challenge-096/paulo-custodio/cpp/ch-1.cpp
parent3d3900a2f0f69c54a34683e4e1b5da007b4af9d9 (diff)
downloadperlweeklychallenge-club-3fa58628535d4041c7cc648c005080ca88f18c18.tar.gz
perlweeklychallenge-club-3fa58628535d4041c7cc648c005080ca88f18c18.tar.bz2
perlweeklychallenge-club-3fa58628535d4041c7cc648c005080ca88f18c18.zip
Replace tabs by spaces so that indentation looks correct
Diffstat (limited to 'challenge-096/paulo-custodio/cpp/ch-1.cpp')
-rw-r--r--challenge-096/paulo-custodio/cpp/ch-1.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/challenge-096/paulo-custodio/cpp/ch-1.cpp b/challenge-096/paulo-custodio/cpp/ch-1.cpp
index 34f4d79c73..51beeb423f 100644
--- a/challenge-096/paulo-custodio/cpp/ch-1.cpp
+++ b/challenge-096/paulo-custodio/cpp/ch-1.cpp
@@ -5,9 +5,9 @@ TASK #1 › Reverse Words
Submitted by: Mohammad S Anwar
You are given a string $S.
-Write a script to reverse the order of words in the given string. The string
-may contain leading/trailing spaces. The string may have more than one space
-between words in the string. Print the result without leading/trailing spaces
+Write a script to reverse the order of words in the given string. The string
+may contain leading/trailing spaces. The string may have more than one space
+between words in the string. Print the result without leading/trailing spaces
and there should be only one space between words.
Example 1:
@@ -21,22 +21,22 @@ Output: "Challenge Weekly The"
#include <sstream>
int main(int argc, char* argv[]) {
- // concatenate all args
- std::string text;
- for (int i = 1; i < argc; i++) {
- text += argv[i];
- text += " ";
- }
-
- // build list of words
- std::vector<std::string> words;
- std::istringstream iss(text);
- std::string word;
- while (iss >> word)
- words.push_back(word);
-
- // print words in reverse order
- for (auto it = words.rbegin(); it != words.rend(); ++it)
- std::cout << *it << " ";
- std::cout << std::endl;
+ // concatenate all args
+ std::string text;
+ for (int i = 1; i < argc; i++) {
+ text += argv[i];
+ text += " ";
+ }
+
+ // build list of words
+ std::vector<std::string> words;
+ std::istringstream iss(text);
+ std::string word;
+ while (iss >> word)
+ words.push_back(word);
+
+ // print words in reverse order
+ for (auto it = words.rbegin(); it != words.rend(); ++it)
+ std::cout << *it << " ";
+ std::cout << std::endl;
}