Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Dato: 03-10-2011
- * Kursus: Imperativ Programming
- * Underviser: Kurt Nørmark
- * Opgave: http://people.cs.aau.dk/~normark/impr-c/control-more-iteration-for-slide-exercise-1.html
- */
- #include <stdlib.h>
- #include <stdio.h>
- #include <math.h>
- #define PI 3.1415926535
- int main() {
- FILE *image_file;
- int i, j;
- int red, green, blue;
- int counter;
- image_file = fopen("out.pnm", "wb");
- // Header
- fputs("P6\n", image_file);
- fputs("500 500\n", image_file);
- fputs("255\n", image_file);
- counter = 0;
- // Rækker
- for(i = 0; i < 500; i++)
- // Søjler
- for (j = 0; j < 500; j++)
- {
- // if(abs(round(sin(i)*500))==j)
- // {
- // fputc(255, image_file);
- // fputc(0, image_file);
- // fputc(0, image_file);
- // }
- // else if(abs(round(cos(i)*500))==j)
- // {
- // fputc(255, image_file);
- // fputc(0, image_file);
- // fputc(0, image_file);
- // }
- fputc(abs(floor(sin(i)*sin(j)*750)) % 256, image_file); // abs(floor(sin(i)*sin(j)*500)) % 256
- fputc(abs(floor(sin(i)*sin(j)*500)) % 256, image_file); // abs(floor(asin(j)*asin(i)*1)) % 256
- fputc(abs(floor(sin(i)*sin(j)*250)) % 256, image_file); // abs(floor(sin(i+j)*asin(i+j)*1)) % 256
- counter++;
- //printf("%d, ", abs(round(cos(i)*500)));
- //printf("%d, ", abs(round(sin(i)*500)));
- }
- fclose(image_file);
- printf("%d", counter);
- return 0;
- }
Add Comment
Please, Sign In to add comment