Skip to content

Instantly share code, notes, and snippets.

@alirezaarzehgar
Last active December 10, 2022 19:06
Show Gist options
  • Select an option

  • Save alirezaarzehgar/b0f7d20287b0371fc07fcb2e374503e6 to your computer and use it in GitHub Desktop.

Select an option

Save alirezaarzehgar/b0f7d20287b0371fc07fcb2e374503e6 to your computer and use it in GitHub Desktop.
A very simple example for students ...
#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