-
I need any one's help
السلام عليكم
بصراحة يا إخوان عندي برنامجين بلغة السي وفاهم وش الغرض من البرنامجين لكن أبي أي واحد منكم لو تكرم يشرحلي
البرنامجين خطوة بخطوة
(أحد البرامج يرسم نقطة على الشاشة والآخر يرسم خط مستقيم).
Please i need them as soon as possible,and i will be so greatful to the one who is intrested in helping
me.
البرنامج الأول:
#include <stdio.h>
#include <dos.h>
#include <graphics.h>
#include <stdlib.h>
#include <io.h>
#include <conio.h>
#include <ctype.h>
main()
{
void far initgraph(int far *graphdriver,int far *graphmode, char far *direct);
int graphdriver;
int graphmode;
graphdriver=EGA;
graphmode=EGAHI;
initgraph(&graphdriver,&graphmode,\\tc2);
setpalette(0,4);
setbkcolor(0);
putpixel(50,50,9);
getche();
}
__________________________________________________________
البرنامج الثاني:
#include <stdio.h>
#include <dos.h>
#include <graphics.h>
#include <stdlib.h>
#include <io.h>
#include <conio.h>
#define ROUND(a) ((int) (a+0.5))
main()
{
void lineDDA(int,int,int,int);
void far initgraph(int far *graphdriver,int far *graphmode, char far *direct);
int graphdriver;
int graphmode;
int x1,y1,x2,y2;
printf("X1=");scanf("%d",&x1);
printf("\nY1=");scanf("%d",&y1);
printf("\nX2=");scanf("%d",&x2);
printf("\nY2=");scanf("%d",&y2);
graphdriver=EGA;
graphmode=EGAHI;
initgraph(&graphdriver,&graphmode,"\\tc2");
setpalette(0,4);
setbkcolor(0);
getche();
lineDDA(x1,y1,x2,y2);
}/*End of main*/
void lineDDA (int xa, int ya, int xb, int yb)
{
int dx=xb-xa, dy=yb-ya, steps,k;
float xincrement,yincrement,x=xa,y=ya;
if(abs(dx)>abs(dy)) steps=abs(dx);
else steps = abs(dy);
xincrement=dx/(float) steps;
yincrement=dy/(float) steps;
setPixel(ROUND(x),ROUND(y));
for (k=0;k<steps;k++){
x+=xincrement;
y+=yincrement;
setPixel (ROUND(x),ROUND(y));
/*getche();*/
}
getche();
}/*End of LineDDA*/
setPixel(x,y)
int x,y;
{
/*putpixel(x,350-y,4);*/
putpixel(x,y,4);
}
ضوابط المشاركة
- لا تستطيع إضافة مواضيع جديدة
- لا تستطيع الرد على المواضيع
- لا تستطيع إرفاق ملفات
- لا تستطيع تعديل مشاركاتك
-
قوانين المنتدى