All pastes #1386757 Raw Edit

Hoppity Hop (division-free)

public c v1 · immutable
#1386757 ·published 2009-04-09 03:52 UTC
rendered paste body
/* * Completely division-free, strlen-free, (hopefully) warning-free, * and (hopefully) error-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 size_t offs[] = {0, 0, 0, 8, 8, 15, 23, 23, 23, 31, 38, 38, 46, 46, 46};static size_tput(size_t len){    return fwrite(text, len, 1, stdout);}intmain(int argc, char **argv){    unsigned int n;    FILE *fp;    if (argc < 2 || !(fp = fopen(argv[1], "r")) || !fscanf(fp, "%u", &n))        return 1;    fclose(fp);    for (; n >= 15; n -= 15)        put(sizeof text - 1);    put(offs[n]);    return 0;}