fork download
  1. #include <stdio.h>
  2.  
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. typedef vector<string> Strings;
  9.  
  10. void print(string const& s) {
  11. printf(s.c_str());
  12. printf("\n");
  13. }
  14.  
  15. void print(Strings const& ss, int i) {
  16. print("Test " + to_string(i));
  17. print("Number of strings: " + to_string(ss.size()));
  18. for (auto& s: ss) {
  19. auto t = "length = " + to_string(s.size()) + ": " + s;
  20. print(t);
  21. }
  22. print("\n");
  23. }
  24.  
  25. void test() {
  26. Strings a{"hello"};
  27. print(a, 1);
  28.  
  29. Strings b{"hello", "there"};
  30. print(b, 2);
  31.  
  32. Strings c{"hello", "there", "kids"};
  33. print(c, 3);
  34. }
  35.  
  36. int main() {
  37. test();
  38. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
Test 1
Number of strings: 1
length = 5: hello


Test 2
Number of strings: 2
length = 5: hello
length = 5: there


Test 3
Number of strings: 3
length = 5: hello
length = 5: there
length = 4: kids