#include <iostream>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int searchXY(int y,int x,int H,int W)
{
return W*y+x;
}
int Min(int a,int b)
{
return a < b? a :b;
}
int Max(int a,int b)
{
return a> b? a:b;
}
void main()
{
double x1=-0.75,y1=-0.5;
double x2=0.6, y2=0.4;
,W=;
double *pix=new double[H*W];
;
;
;
;
;
int xMin=Min(X1,X2);
int xMax=Max(X1,X2);
k=(Y2-Y1)/(X2-X1);
for (int x=xMin;x<xMax;x++)
{
double b=Y1-k*X1;
int y=k*x+b;
pix[searchXY(y+H/,x+W/,H,W)]=;
}
int yMin=Min(Y1,Y2);
int yMax=Max(Y1,Y2);
k=(X2-X1)/(Y2-Y1);
for (int y=yMin;y<yMax;y++)
{
double b=X1-k*Y1;
int x=k*y+b;
pix[searchXY(y+H/,x+W/,H,W)]=;
}
FILE *f=fopen("img.ppm","w");
fprintf(f,);
;i<W*H;i++)
fprintf(f,"%d %d %d\n",int(pix[i]),int(pix[i]),int(pix[i]));
fclose(f);
delete[] pix;
}