Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Copyright (c) 2012 by Bash Vi
- // This code is released under the terms
- // of the WTFPL (What the Fuck Pulic License) version 2.0
- // http://sam.zoy.org/wtfpl/
- // ___
- // 3| 2 |4
- // |___|
- // 5| 1 |6
- // |___|
- // 0
- #include <iostream>
- #include <boost/program_options.hpp>
- #include <sstream>
- #include <cstring>
- #include <bitset>
- #include <map>
- using namespace std;
- namespace po = boost::program_options;
- map<char, char> mymap;
- string convert(int number)
- {
- stringstream stream;
- stream << number;
- return stream.str();
- }
- // function copied (and then modified) from here:
- // http://icfun.blogspot.ch/2009/04/get-n-th-bit-value-of-any-integer.html
- // all rights stay with the original author.
- // This function's copyright might differ from the rest of the program!
- bool bit_set(char chr, int i)
- {
- int con = 1 << (i-1);
- return chr & con;
- }
- void draw(char c, int i)
- {
- // 0,1,2 ==> _
- // 2,4,5,6 ==> |
- if(bit_set(mymap.find(c)->second, i+1))
- {
- if(i>2)
- {
- cout << "|";
- }
- else
- {
- cout << "_";
- }
- }
- else
- {
- cout << " ";
- }
- }
- int main(int ac, char* av[])
- {
- int number = 0;
- po::options_description generic("Generic options");
- generic.add_options()
- ("version,v", "Print version string")
- ("help,h", "Show this help message");
- po::options_description hidden("Hidden options");
- hidden.add_options()
- ("number", po::value<int>(&number), "Number to print");
- po::options_description cmdline_options;
- cmdline_options.add(generic).add(hidden);
- po::options_description visible("Allowed options");
- visible.add(generic);
- po::positional_options_description p;
- p.add("number", -1);
- po::variables_map vm;
- store(po::command_line_parser(ac, av).options(cmdline_options).positional(p).run(), vm);
- notify(vm);
- if(vm.count("help"))
- {
- cout << visible << "\n";
- return 0;
- }
- if(vm.count("version"))
- {
- cout << "This is version 0.5" << "\n";
- return 0;
- }
- string str = convert(number);
- char cstr[str.size()+1];
- strcpy( cstr, str.c_str());
- mymap.insert( pair <char, char> ('1', 'P'));
- mymap.insert( pair <char, char> ('2', '7'));
- mymap.insert( pair <char, char> ('3', 'W'));
- mymap.insert( pair <char, char> ('4', 'Z'));
- mymap.insert( pair <char, char> ('5', 'O'));
- mymap.insert( pair <char, char> ('6', 'o'));
- mymap.insert( pair <char, char> ('7', 'T'));
- // unable to write 01111111 char...
- char c1 = '?';
- char c2 = '@';
- mymap.insert( pair <char, char> ('8', c1 | c2)); // not yet solved
- mymap.insert( pair <char, char> ('9', '_'));
- mymap.insert( pair <char, char> ('0', '}'));
- for(int i=0; i< strlen(cstr); i++)
- {
- cout << " ";
- draw(cstr[i], 2);
- cout << " ";
- }
- cout << endl;
- for(int i=0; i< strlen(cstr); i++)
- {
- draw(cstr[i], 3);
- draw(cstr[i], 1);
- draw(cstr[i], 4);
- }
- cout << endl;
- for(int i=0; i< strlen(cstr); i++)
- {
- draw(cstr[i], 5);
- draw(cstr[i], 0);
- draw(cstr[i], 6);
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment