Last active
December 10, 2022 19:06
-
-
Save alirezaarzehgar/b0f7d20287b0371fc07fcb2e374503e6 to your computer and use it in GitHub Desktop.
A very simple example for students ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| int main() | |
| { | |
| int n; | |
| bool caps = false; | |
| cin >> n; | |
| string result; | |
| while(n--) | |
| { | |
| string str; | |
| char ch; | |
| cin >> str; | |
| if (str == "CAPS") { | |
| caps = !caps; | |
| continue; | |
| } | |
| ch = str[0]; | |
| if (caps) { | |
| result += ch <= 'Z' ? tolower(ch) : toupper(ch); | |
| continue; | |
| } | |
| result += ch; | |
| } | |
| cout << result << endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment