Created
April 1, 2014 23:35
-
-
Save hollasch/9925199 to your computer and use it in GitHub Desktop.
Runnable form of Duff's Device, written for clarity.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void send (int count) | |
{ | |
int n = (count+7) / 8; | |
switch (count % 8) { | |
do { | |
case 0: printf("%d.8\n", n); | |
case 7: printf("%d.7\n", n); | |
case 6: printf("%d.6\n", n); | |
case 5: printf("%d.5\n", n); | |
case 4: printf("%d.4\n", n); | |
case 3: printf("%d.3\n", n); | |
case 2: printf("%d.2\n", n); | |
case 1: printf("%d.1\n", n); | |
} while (--n > 0); | |
} | |
} | |
int main (int arc, char *argv[]) | |
{ | |
send (atoi(argv[1])); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment