Skip to content

Instantly share code, notes, and snippets.

@sndnvaps
Created December 7, 2013 08:12
Show Gist options
  • Save sndnvaps/7838542 to your computer and use it in GitHub Desktop.
Save sndnvaps/7838542 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
using namespace std;
class table {
private:
string number;
string big_num;
public:
table(string num) {
number = num;
}
void print_table() {
if (atoi(number.c_str()) < 0) {
cout << "input number" << number.c_str() << "less then zero" << endl;
return;
} else if ( 0 < atoi(number.c_str()) < 9) {
big_num = number;
char bigDigits[10][256] = {
{ " 000 \n"
"0 0 \n"
"0 0 \n"
"0 0 \n"
" 0 0 \n"
" 000 \n"},
{" 11 \n"
" 11 \n"
" 11 \n"
" 11 \n"
" 11 \n"
" 11 \n"},
{" 222 \n"
" 2 2 \n"
" 2 \n"
" 2 \n"
" 2 \n"
" 2222 \n"},
{" 333 \n"
" 3 \n"
" 333 \n"
" 3 \n"
" 333 \n"
" \n"},
{" 4 \n"
" 4 4 \n"
" 4 4 \n"
" 44444 \n"
" 4 \n"
" 4 \n"},
{" 5555 \n"
" 5 \n"
" 555 \n"
" 5 \n"
" 5 \n"
" 555 \n"},
{" 6 \n"
" 6 \n"
" 6666 \n"
" 6 6 \n"
" 6 6 \n"
" 666 \n"},
{" 77777 \n"
" 7 \n"
" 7 \n"
" 7 \n"
" 7 \n"
" 7 \n"},
{" 8 \n"
" 8 8 \n"
" 8 \n"
" 8 8 \n"
" 8 \n"
" \n"},
{" 9999 \n"
" 9 9 \n"
" 9999 \n"
" 9 \n"
" 9 \n"
" 9 \n"},
};
int i = 0;
int j = 0;
j = atoi(big_num.c_str());
for (int p = 0; p < 9; p++) {
char *table = bigDigits[p];
if (j == p) {
cout << table << endl;
}
}
}
}
};
int main(int argc, char *argv[]) {
if (argc < 2) {
cout << "big-number number " << endl;
} else {
table t(argv[1]);
//table t("0");
t.print_table();
}
return 0;
}
@sndnvaps
Copy link
Author

sndnvaps commented Dec 7, 2013

只能说,这个方法很二。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment