All pastes #1386736 Raw Edit

Hoppity Hop (division-free)

public c v1 · immutable
#1386736 ·published 2009-04-09 03:21 UTC
rendered paste body
/* * Completely division-free implementation of Hoppity Hop. :-) * Copyright (c) 2009 Chris K. Jester-Young; GPLv3+. */#include <stdio.h>static const char text[] = "Hoppity\nHophop\nHoppity\nHoppity\nHophop\nHoppity\nHop\n";static const int offs[] = {0, 0, 0, 8, 8, 15, 23, 23, 23, 31, 38, 38, 46, 46, 46};intmain(int argc, char **argv){    int n;    FILE *fp;    if (argc < 2 || !(fp = fopen(argv[1], "r")) || !fscanf(fp, "%d", &n))        return 1;    fclose(fp);    for (; n >= 15; n -= 15)        fwrite(text, sizeof text - 1, 1, stdout);    fwrite(text, offs[n], 1, stdout);    return 0;}