Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- char TU(char c) // TO UPPER
- {
- if (c == 'a')
- c = 'A';
- else if (c == 'b')
- c = 'B';
- else if (c == 'c')
- c = 'C';
- else if (c == 'd')
- c = 'D';
- else if (c == 'e')
- c = 'E';
- else if (c == 'f')
- c = 'F';
- else if (c == 'g')
- c = 'G';
- else if (c == 'h')
- c = 'H';
- else if (c == 'i')
- c = 'I';
- else if (c == 'j')
- c = 'J';
- else if (c == 'k')
- c = 'K';
- else if (c == 'l')
- c = 'L';
- else if (c == 'm')
- c = 'M';
- else if (c == 'n')
- c = 'N';
- else if (c == 'o')
- c = 'O';
- else if (c == 'p')
- c = 'P';
- else if (c == 'q')
- c = 'Q';
- else if (c == 'r')
- c = 'R';
- else if (c == 's')
- c = 'S';
- else if (c == 't')
- c = 'T';
- else if (c == 'u')
- c = 'U';
- else if (c == 'v')
- c = 'V';
- else if (c == 'w')
- c = 'W';
- else if (c == 'x')
- c = 'X';
- else if (c == 'y')
- c = 'Y';
- else if (c == 'z')
- c = 'Z';
- else
- c = c;
- return c;
- }
- char TL(char c) // TO LOWER
- {
- if (c == 'A')
- c = 'a';
- else if (c == 'B')
- c = 'b';
- else if (c == 'C')
- c = 'c';
- else if (c == 'D')
- c = 'd';
- else if (c == 'E')
- c = 'e';
- else if (c == 'F')
- c = 'f';
- else if (c == 'G')
- c = 'g';
- else if (c == 'H')
- c = 'h';
- else if (c == 'I')
- c = 'i';
- else if (c == 'J')
- c = 'j';
- else if (c == 'K')
- c = 'k';
- else if (c == 'L')
- c = 'l';
- else if (c == 'M')
- c = 'm';
- else if (c == 'N')
- c = 'n';
- else if (c == 'O')
- c = 'o';
- else if (c == 'P')
- c = 'p';
- else if (c == 'Q')
- c = 'q';
- else if (c == 'R')
- c = 'r';
- else if (c == 'S')
- c = 's';
- else if (c == 'T')
- c = 't';
- else if (c == 'U')
- c = 'u';
- else if (c == 'V')
- c = 'v';
- else if (c == 'W')
- c = 'w';
- else if (c == 'X')
- c = 'x';
- else if (c == 'Y')
- c = 'y';
- else if (c == 'Z')
- c = 'z';
- else
- c = c;
- return c;
- }
- bool IE(int i) // IS EVEN
- {
- bool* NEN = new bool[2147483649]; // NEGATIVE EVEN NUMBERS
- bool* PEN = new bool[2147483649]; // POSITIVE EVEN NUMBERS
- for (long long j = -2147483648LL; j < 2147483647LL; j += 2)
- {
- if (j < 0) {
- long long tmp = -j;
- NEN[tmp] = true;
- }
- else if (j >= 0)
- PEN[j] = true;
- }
- bool r;
- if (i < 0)
- {
- long long tmp = -(long long)i;
- if (NEN[tmp] == true)
- r = true;
- else if (PEN[tmp] == true)
- r = true;
- else
- r = false;
- }
- else if (i >= 0)
- {
- if (NEN[i] == true)
- r = true;
- else if (PEN[i] == true)
- r = true;
- else
- r = false;
- }
- // no memory leaks here :)
- delete[] NEN;
- delete[] PEN;
- return r;
- }
- bool IO(int i) // IS ODD
- {
- bool* NON = new bool[2147483649]; // NEGATIVE ODD NUMBERS
- bool* PON = new bool[2147483649]; // POSITIVE ODD NUMBERS
- for (long long j = -2147483647LL; j < 2147483647LL; j += 2)
- {
- if (j < 0) {
- long long tmp = -j;
- NON[tmp] = true;
- }
- else if (j >= 0)
- PON[j] = true;
- }
- bool r;
- if (i < 0)
- {
- long long tmp = -(long long)i;
- if (NON[tmp] == true)
- r = true;
- else if (PON[tmp] == true)
- r = true;
- else
- r = false;
- }
- else if (i >= 0)
- {
- if (NON[i] == true)
- r = true;
- else if (PON[i] == true)
- r = true;
- else
- r = false;
- }
- // no memory leaks here :)
- delete[] NON;
- delete[] PON;
- return r;
- }
- bool IL(char c) // IS LETTER
- {
- if (c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E' || c == 'F' || c == 'G' || c == 'H' || c == 'I' || c == 'J' || c == 'K' || c == 'L' || c == 'M' || c == 'N' || c == 'O' || c == 'P' || c == 'Q' || c == 'R' || c == 'S' || c == 'T' || c == 'U' || c == 'V' || c == 'W' || c == 'X' || c == 'Y' || c == 'Z')
- return true;
- else if (c == 'a' || c == 'b' || c == 'c' || c == 'd' || c == 'e' || c == 'f' || c == 'g' || c == 'h' || c == 'i' || c == 'j' || c == 'k' || c == 'l' || c == 'm' || c == 'n' || c == 'o' || c == 'p' || c == 'q' || c == 'r' || c == 's' || c == 't' || c == 'u' || c == 'v' || c == 'w' || c == 'x' || c == 'y' || c == 'z')
- return true;
- else
- return false;
- }
- void TWC(string &s) // TO WEIRD CASE
- {
- static int i = -1;
- static int nlc = 0; //NON LETTER COUNTER
- i++;
- if (i == s.size())
- return;
- if (IL(s[i]) == false)
- nlc++;
- if (IE(i-nlc) == true)
- s[i] = TL(s[i]);
- else if (IO(i-nlc) == true)
- s[i] = TU(s[i]);
- TWC(s);
- }
- int main()
- {
- string input = "Hello world";
- cout << input << endl;
- TWC(input);
- cout << input << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment