回答編集履歴

1

追記

2020/04/29 11:40

投稿

episteme
episteme

スコア16612

test CHANGED
@@ -51,3 +51,49 @@
51
51
  }
52
52
 
53
53
  ```
54
+
55
+
56
+
57
+ [追記] <cctype> 使えとの思し召しなら:
58
+
59
+ ```C++
60
+
61
+ #include <iostream>
62
+
63
+ #include <string>
64
+
65
+ #include <algorithm>
66
+
67
+ #include <cctype>
68
+
69
+
70
+
71
+ std::string change(const std::string& str) {
72
+
73
+ std::string result(str.size(),'\0');
74
+
75
+ std::transform(str.begin(), str.end(), result.begin(),
76
+
77
+ [](char ch) { return isupper(ch) ? tolower(ch) :
78
+
79
+ (islower(ch) ? toupper(ch) : ch); });
80
+
81
+ return result;
82
+
83
+ }
84
+
85
+
86
+
87
+ int main() {
88
+
89
+ std::string line;
90
+
91
+ while ( std::getline(std::cin, line) && line.size() != 0 ) {
92
+
93
+ std::cout << '[' << line << "] -> [" << change(line) << "]\n";
94
+
95
+ }
96
+
97
+ }
98
+
99
+ ```