Created
August 23, 2012 03:44
-
-
Save chunkyguy/3432031 to your computer and use it in GitHub Desktop.
height of stupidity
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
/* | |
This piece of shit that I wrote does one simple task: linearly interpolate between 0.0 and 1.0 for the value 'res'. | |
This is a sample run: | |
$ ./mix 1 | |
0: 0.500000 | |
$ ./mix 2 | |
0: 0.333333 | |
1: 0.666667 | |
$ ./mix 3 | |
0: 0.250000 | |
1: 0.500000 | |
2: 0.750000 | |
This is how it could have been done in a more sensible way | |
float dt = 1.0/res; | |
for(i = 0; i < res; i++){ | |
float point = dt * i; | |
printf("%d: %f\n",i,point); | |
} | |
*/ | |
#include<stdio.h> | |
#include<stdlib.h> | |
int main(int argc, char *argv[]){ | |
int res; | |
int i; | |
if(argc != 2){ | |
printf("Usage: %s <resolution>\n",argv[0]); | |
return 0; | |
} | |
res = atoi(argv[1]); | |
for(i = 0; i < res; i++){ | |
float point = 1.0/(float)(res+1)*(i+1.0); | |
printf("%d: %f\n",i,point); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment