Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- void print_headers();
- void print_exception();
- void print_functions(char c);
- void from_to(char c, char d);
- void print_main();
- int main()
- {
- print_headers();
- std::printf("\n");
- print_exception();
- std::printf("\n");
- for(char c = 'A'; c <= 'Z'; ++c)
- {
- print_functions(c);
- }
- print_main();
- std::printf("\n");
- }
- void print_headers()
- {
- std::printf("#include <exception>\n"\
- "#include <string>\n"\
- "#include <iostream>\n");
- }
- void print_exception()
- {
- std::printf("struct WrongChar : public std::exception\n"\
- "{\n"\
- " const char* what() const throw()\n"\
- " {\n"\
- " return \"Wrong input char\";\n"\
- " }\n"\
- "};\n");
- }
- void print_functions(char c)
- {
- from_to(c, c + 32);
- std::printf("\n");
- from_to(c + 32, c);
- std::printf("\n");
- }
- void from_to(char c, char d)
- {
- std::printf("char %c_to_%c(char c)\n"\
- "{\n"\
- " if(c != '%c')\n"\
- " {\n"\
- " throw WrongChar();\n"\
- " }\n"
- " return '%c';\n"\
- "}\n", c, d, c, d);
- }
- void print_main()
- {
- std::printf(
- "// std is just bloat\n"\
- "using namespace std;\n"\
- "int main(int count, char* values[])\n"\
- "{\n"\
- " // it is easier to work with c++ string then c string\n"\
- " string text;\n"\
- " int counter = 0;\n"\
- " while(values[counter] != 0)\n"\
- " {\n"\
- " text = text = values[counter];\n"\
- " counter = counter + 1;\n"\
- " }\n"\
- "\n"\
- " counter = 0;\n"\
- " bool make_small = true;\n"\
- " bool make_big = false;\n"\
- "\n"\
- " while(text[counter] != 0)\n"\
- " {\n"
- " if(make_small == true && make_big == false)\n"\
- " {\n"
- );
- for(char c = 'A'; c <= 'Z'; ++c)
- {
- std::printf(
- " try\n"\
- " {\n"\
- " char c;\n"\
- " c = %c_to_%c(text[counter]);\n"\
- " text[counter] = c;\n"\
- " }\n"\
- " catch(...)\n"\
- " {\n"\
- " }\n\n", c, c + 32);
- }
- std::printf(
- " make_small = false;\n"\
- " make_big = true;\n"\
- " }\n"\
- " else if(make_small == false && make_big == true)\n"\
- " {\n"
- );
- for(char c = 'A'; c <= 'Z'; ++c)
- {
- std::printf(
- " try\n"\
- " {\n"\
- " char c;\n"\
- " c = %c_to_%c(text[counter]);\n"\
- " text[counter] = c;\n"\
- " }\n"\
- " catch(...)\n"\
- " {\n"\
- " }\n\n", c + 32, c);
- }
- std::printf(
- " make_small = true;\n"\
- " make_big = false;\n"\
- " }\n"
- );
- std::printf(
- " counter = counter + 1;\n"\
- " }\n"\
- "\n"\
- " cout << text << endl;\n"\
- "\n"\
- " return 0;\n"\
- "}\n"
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement