Skip to content

Instantly share code, notes, and snippets.

@funrep
Created September 22, 2012 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save funrep/3767489 to your computer and use it in GitHub Desktop.
Save funrep/3767489 to your computer and use it in GitHub Desktop.
mindfuck
#include <stdio.h>
main()
{
int c, i, nwhite, nother;
int ndigit[10]; /* okey, so this make a "array" with 10 variables/values in it? */
nwhite = nother = 0;
for (i = 0; i < 10; ++i)
ndigit[i] = 0; /*this makes each value/varibale of ndigit to 0?*/
while ((c = getchar()) != EOF)
if (c >= '0' && c <= '9')
++ndigit[c-'0']; /* i dont understand this, is it: ndigit[c-48]=ndigit+1 or something? */
else if (c == ' ' || c == '\n' || c == '\t')
++nwhite;
else;
++nother;
printf(" 0 1 2 3 4 5 6 7 8 9\n");
printf("digits =");
for (i = 0; i < 10; ++i)
printf(" %d", ndigit[i]);
printf(" white space = %d other = %d\n", nwhite, nother);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment