Coffeehouse Post

Single Post Permalink

View Thread: Brilliant Code! Got Some?
  • User profile image
    jsampsonPC

    Just found this one online:

    #include <stdio.h>

    typedef struct {
        int ch;
        int count;
    } star_t;

    int main(void) {
        star_t foo[] = {
    {46, 22}, {47, 1}, {194, 1}, {180, 1}, {194, 1}, {175, 1}, {47, 1}, {41, 1}, {'\n', 1},
    {46, 20}, {44, 1}, {47, 1}, {194, 1}, {175, 1}, {46, 2}, {47, 1}, {'\n', 1},
    {46, 19}, {47, 1}, {46, 4}, {47, 1}, {'\n', 1},
    {46, 13}, {47, 1}, {194, 1}, {180, 1}, {194, 1}, {175, 1}, {47, 1}, {39, 1}, {46, 3}, {39, 1}, {47, 1}, {194, 1}, {180, 1}, {194, 1}, {175, 1}, {194, 1}, {175, 1}, {96, 1}, {194, 1}, {183, 1}, {194, 1}, {184, 1}, {'\n', 1},
    {46, 10}, {47, 1}, {39, 1}, {47, 1}, {46, 3}, {47, 1}, {46, 4}, {47, 1}, {46, 7}, {47, 1}, {194, 1}, {168, 1}, {194, 1}, {175, 1}, {92, 1}, {'\n', 1},
    {46, 8}, {40, 1}, {39, 1}, {40, 1}, {46, 3}, {194, 1}, {180, 1}, {46, 3}, {194, 1}, {180, 1}, {46, 4}, {32, 1}, {194, 1}, {175, 1}, {126, 1}, {47, 1}, {39, 1}, {46, 3}, {39, 1}, {41, 1}, {'\n', 1},
    {46, 9}, {92, 1}, {46, 17}, {39, 1}, {46, 5}, {47, 1}, {'\n', 1},
    {46, 10}, {39, 2}, {46, 3}, {92, 1}, {46, 10}, {32, 1}, {95, 1}, {46, 1}, {194, 1}, {183, 1}, {194, 1}, {180, 1}, {'\n', 1},
    {46, 12}, {92, 1}, {46, 14}, {40, 1}, {'\n', 1},
    {46, 14}, {92, 1}, {46, 13}, {92, 1}, {46, 1}, {32, 1}, {'\n', 1}
        };
        int i, j;
        for (i = 0; i < sizeof(foo) / sizeof(foo[0]); i++) {
            star_t bar = foo[i];
            for (j = 0; j < bar.count; j++) {
                printf("%c", (char )bar.ch);
            }
        }
        return 0;
    }