/*
http://t...content-available-to-author-only...h.net/test/read.cgi/tech/1359210850/809
[ プログラム ] スレ立てるまでもない質問はここで 124匹目
809 名前:デフォルトの名無しさん [sage]: 2013/02/19(火) 11:34:36.66
a-zA-Z0-9の範囲の文字列で3桁の数字を全パターン出力するコード
言語は問いません
*/
#include <stdio.h>
#define BASE (26 + 26 + 10)
int main()
{
char moji[BASE], *p, pr[4];
char ch;
int i, j, d;
// init
p = moji;
for (ch = 'a'; ch <= 'z'; ch++)
*p++ = ch;
for (ch = 'A'; ch <= 'Z'; ch++)
*p++ = ch;
for (ch = '0'; ch <= '9'; ch++)
*p++ = ch;
// printf
pr[3] = '\0';
for (i = 0; i < BASE * BASE * BASE; i++) {
d = i;
p = &pr[2];
for (j = 0; j < 3; j++) {
*p-- = moji[d % BASE];
d /= BASE;
}
}
// end
return 0;
}
LyoKICAgIGh0dHA6Ly90Li4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5oLm5ldC90ZXN0L3JlYWQuY2dpL3RlY2gvMTM1OTIxMDg1MC84MDkKICAgIFsg44OX44Ot44Kw44Op44OgIF0g44K544Os56uL44Gm44KL44G+44Gn44KC44Gq44GE6LOq5ZWP44Gv44GT44GT44GnIDEyNOWMueebrgogICAgICAgIDgwOSDlkI3liY3vvJrjg4fjg5Xjgqnjg6vjg4jjga7lkI3nhKHjgZfjgZXjgpMgW3NhZ2Vd77yaIDIwMTMvMDIvMTko54GrKSAxMTozNDozNi42NiAgIAogICAgICAgIGEtekEtWjAtOeOBruevhOWbsuOBruaWh+Wtl+WIl+OBpzPmoYHjga7mlbDlrZfjgpLlhajjg5Hjgr/jg7zjg7Plh7rlipvjgZnjgovjgrPjg7zjg4kKICAgICAgICDoqIDoqp7jga/llY/jgYTjgb7jgZvjgpMgCiAqLwojaW5jbHVkZSA8c3RkaW8uaD4KCiNkZWZpbmUgQkFTRSAgKDI2ICsgMjYgKyAxMCkKCmludCBtYWluKCkKewogICAgY2hhciBtb2ppW0JBU0VdLCAqcCwgcHJbNF07CiAgICBjaGFyIGNoOwogICAgaW50IGksIGosIGQ7CgogICAgLy8gaW5pdAogICAgcCA9IG1vamk7CiAgICBmb3IgKGNoID0gJ2EnOyBjaCA8PSAneic7IGNoKyspCiAgICAgICAgKnArKyA9IGNoOwogICAgZm9yIChjaCA9ICdBJzsgY2ggPD0gJ1onOyBjaCsrKQogICAgICAgICpwKysgPSBjaDsKICAgIGZvciAoY2ggPSAnMCc7IGNoIDw9ICc5JzsgY2grKykKICAgICAgICAqcCsrID0gY2g7CgogICAgLy8gcHJpbnRmCiAgICBwclszXSA9ICdcMCc7CiAgICBmb3IgKGkgPSAwOyBpIDwgQkFTRSAqIEJBU0UgKiBCQVNFOyBpKyspIHsKICAgICAgICBkID0gaTsKICAgICAgICBwID0gJnByWzJdOwogICAgICAgIGZvciAoaiA9IDA7IGogPCAzOyBqKyspIHsKICAgICAgICAgICAgKnAtLSA9IG1vamlbZCAlIEJBU0VdOwogICAgICAgICAgICBkIC89IEJBU0U7CiAgICAgICAgfQogICAgICAgIHByaW50ZigiJXNcbiIsIHByKTsKICAgIH0KCiAgICAvLyBlbmQKICAgIHJldHVybiAwOwp9Cg==