Guest User

Badcode 13

a guest
Jun 19th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. char TU(char c) // TO UPPER
  6. {
  7.     if (c == 'a')
  8.         c = 'A';
  9.     else if (c == 'b')
  10.         c = 'B';
  11.     else if (c == 'c')
  12.         c = 'C';
  13.     else if (c == 'd')
  14.         c = 'D';
  15.     else if (c == 'e')
  16.         c = 'E';
  17.     else if (c == 'f')
  18.         c = 'F';
  19.     else if (c == 'g')
  20.         c = 'G';
  21.     else if (c == 'h')
  22.         c = 'H';
  23.     else if (c == 'i')
  24.         c = 'I';
  25.     else if (c == 'j')
  26.         c = 'J';
  27.     else if (c == 'k')
  28.         c = 'K';
  29.     else if (c == 'l')
  30.         c = 'L';
  31.     else if (c == 'm')
  32.         c = 'M';
  33.     else if (c == 'n')
  34.         c = 'N';
  35.     else if (c == 'o')
  36.         c = 'O';
  37.     else if (c == 'p')
  38.         c = 'P';
  39.     else if (c == 'q')
  40.         c = 'Q';
  41.     else if (c == 'r')
  42.         c = 'R';
  43.     else if (c == 's')
  44.         c = 'S';
  45.     else if (c == 't')
  46.         c = 'T';
  47.     else if (c == 'u')
  48.         c = 'U';
  49.     else if (c == 'v')
  50.         c = 'V';
  51.     else if (c == 'w')
  52.         c = 'W';
  53.     else if (c == 'x')
  54.         c = 'X';
  55.     else if (c == 'y')
  56.         c = 'Y';
  57.     else if (c == 'z')
  58.         c = 'Z';
  59.     else
  60.         c = c;
  61.     return c;
  62. }
  63.  
  64. char TL(char c) // TO LOWER
  65. {
  66.     if (c == 'A')
  67.         c = 'a';
  68.     else if (c == 'B')
  69.         c = 'b';
  70.     else if (c == 'C')
  71.         c = 'c';
  72.     else if (c == 'D')
  73.         c = 'd';
  74.     else if (c == 'E')
  75.         c = 'e';
  76.     else if (c == 'F')
  77.         c = 'f';
  78.     else if (c == 'G')
  79.         c = 'g';
  80.     else if (c == 'H')
  81.         c = 'h';
  82.     else if (c == 'I')
  83.         c = 'i';
  84.     else if (c == 'J')
  85.         c = 'j';
  86.     else if (c == 'K')
  87.         c = 'k';
  88.     else if (c == 'L')
  89.         c = 'l';
  90.     else if (c == 'M')
  91.         c = 'm';
  92.     else if (c == 'N')
  93.         c = 'n';
  94.     else if (c == 'O')
  95.         c = 'o';
  96.     else if (c == 'P')
  97.         c = 'p';
  98.     else if (c == 'Q')
  99.         c = 'q';
  100.     else if (c == 'R')
  101.         c = 'r';
  102.     else if (c == 'S')
  103.         c = 's';
  104.     else if (c == 'T')
  105.         c = 't';
  106.     else if (c == 'U')
  107.         c = 'u';
  108.     else if (c == 'V')
  109.         c = 'v';
  110.     else if (c == 'W')
  111.         c = 'w';
  112.     else if (c == 'X')
  113.         c = 'x';
  114.     else if (c == 'Y')
  115.         c = 'y';
  116.     else if (c == 'Z')
  117.         c = 'z';
  118.     else
  119.         c = c;
  120.     return c;
  121. }
  122.  
  123. bool IE(int i) // IS EVEN
  124. {
  125.  
  126.     bool* NEN = new bool[2147483649]; // NEGATIVE EVEN NUMBERS
  127.     bool* PEN = new bool[2147483649]; // POSITIVE EVEN NUMBERS
  128.  
  129.     for (long long j = -2147483648LL; j < 2147483647LL; j += 2)
  130.     {
  131.         if (j < 0) {
  132.             long long tmp = -j;
  133.             NEN[tmp] = true;
  134.         }
  135.         else if (j >= 0)
  136.             PEN[j] = true;
  137.     }
  138.     bool r;
  139.     if (i < 0)
  140.     {
  141.         long long tmp = -(long long)i;
  142.         if (NEN[tmp] == true)
  143.             r = true;
  144.         else if (PEN[tmp] == true)
  145.             r = true;
  146.         else
  147.             r = false;
  148.     }
  149.     else if (i >= 0)
  150.     {
  151.         if (NEN[i] == true)
  152.             r = true;
  153.         else if (PEN[i] == true)
  154.             r = true;
  155.         else
  156.             r = false;
  157.     }
  158.  
  159.     // no memory leaks here :)
  160.     delete[] NEN;
  161.     delete[] PEN;
  162.     return r;
  163. }
  164.  
  165. bool IO(int i) // IS ODD
  166. {
  167.  
  168.     bool* NON = new bool[2147483649]; // NEGATIVE ODD NUMBERS
  169.     bool* PON = new bool[2147483649]; // POSITIVE ODD NUMBERS
  170.  
  171.     for (long long j = -2147483647LL; j < 2147483647LL; j += 2)
  172.     {
  173.         if (j < 0) {
  174.             long long tmp = -j;
  175.             NON[tmp] = true;
  176.         }
  177.         else if (j >= 0)
  178.             PON[j] = true;
  179.     }
  180.     bool r;
  181.     if (i < 0)
  182.     {
  183.         long long tmp = -(long long)i;
  184.         if (NON[tmp] == true)
  185.             r = true;
  186.         else if (PON[tmp] == true)
  187.             r = true;
  188.         else
  189.             r = false;
  190.     }
  191.     else if (i >= 0)
  192.     {
  193.         if (NON[i] == true)
  194.             r = true;
  195.         else if (PON[i] == true)
  196.             r = true;
  197.         else
  198.             r = false;
  199.     }
  200.  
  201.     // no memory leaks here :)
  202.     delete[] NON;
  203.     delete[] PON;
  204.     return r;
  205. }
  206.  
  207. bool IL(char c) // IS LETTER
  208. {
  209.     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')
  210.         return true;
  211.     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')
  212.         return true;
  213.     else
  214.         return false;
  215. }
  216.  
  217. void TWC(string &s) // TO WEIRD CASE
  218. {
  219.     static int i = -1;
  220.     static int nlc = 0; //NON LETTER COUNTER
  221.     i++;
  222.     if (i == s.size())
  223.         return;
  224.  
  225.     if (IL(s[i]) == false)
  226.         nlc++;
  227.  
  228.     if (IE(i-nlc) == true)
  229.         s[i] = TL(s[i]);
  230.     else if (IO(i-nlc) == true)
  231.         s[i] = TU(s[i]);
  232.  
  233.     TWC(s);
  234. }
  235.  
  236. int main()
  237. {
  238.     string input = "Hello world";
  239.  
  240.     cout << input << endl;
  241.     TWC(input);
  242.     cout << input << endl;
  243.     return 0;
  244. }
Advertisement
Add Comment
Please, Sign In to add comment