1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include <stdio.h>
void main() {
FILE *fp;
int i, j,b,temp;
int a[324][195];
fp=fopen("moulin1.ppm","r");
for (i = 1; i < 324; i++)
{
for (j = 1; j < 195; j++)
{
fscanf(fp,"%d",&a[i][j]);
}
}
fclose(fp);
/*fp=fopen("Moulin2.ppm","w");
fprintf(fp,"P");
for (i = 1; i < 324; i++)
{
for (j = 1; j < 195; j++)
fprintf(fp,"%d ", a[i][j]);
fprintf(fp,"\n");
}
fclose(fp);*/
fp=fopen("fliphorizontal.ppm","w");
fprintf(fp,"P3\n");
fprintf(fp,"65 108\n");
fprintf(fp,"255\n");
for (i = 1; i < 324; i++)
/*{if (i == 1)
{for (b =5; b < 195; b++)
j=324-i;
temp=a[i][b];
a[i][b]=a[j][b];
a[j][b]=temp;
fprintf(fp,"%d ", a[i][b]);
fprintf(fp,"\n");
fprintf(fp,"%d ", a[j][b]);
fprintf(fp,"\n");}
else*/ {for (b =1; b < 195; b++)
{j=324-i;
if (i<j)
{
temp=a[i][b];
a[i][b]=a[j][b];
a[j][b]=temp;
fprintf(fp,"%d ", a[j][b]);
fprintf(fp,"%d ", a[i][b]);}
else break;}
}
fclose(fp);
} |
Partager