Em đang học về C. thầy bắt làm trên DEV C mà DEV C/C++ em cài đồ họa nó chỉ chạy được cho C++ mà C nó lại lỗi tùm lum hết cả. Nhờ mọi người xem chương trình có lỗi nào không rồi chuyển qua C++ cho em hoặc có cách nào chạy được đồ họa trên DEV tốt không ạ? Em cảm ơn.
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <stdlib.h>
#define di_chuyen(x,y,k) tao_khoi(x,y,k); xoa_khoi(x,y,k); delay(t);
int t; //toc do di chuyen
int a[]={0,3,5,7,9,11,13,15,17,19,21,23,25}; //Do dai khoi
int mau[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13}; //Mau cua khoi
int mau_nen=0;
void tao_khoi(int x,int y,int k);
void xoa_khoi(int x,int y, int k);
void dung_thap(int x,int y,int m);
void chuyen_khoi(int x1,int y1,int x2,int y2,int k);
void chuyen_thap(int x1,int y1,int x2,int y2,int x3,int y3,int m);
void tao_khoi(int x,int y,int k)
{
int h=a[k]/2;
window(x-h,y,x+h,y);
textbackground(mau[k]);
textcolor(mau[k]); clrscr();
}
void xoa_khoi(int x,int y,int k)
{
int h=a[k]/2;
window(x-h,x+h,y);
textbackground(mau_nen); clrscr();
}
void dung_thap(int x,int y,int m)
{
int i;
for(i=m;i>=1;i--) tao_khoi(x,y-m+i,i);
}
void chuyen_khoi(int x1,int y1,int x2,int y2,int k)
{
static sl_chuyen=0;
int x,y;
sl_chuyen++;
window(1,1,24,1);
textbackground(BLUE); clrscr();
textcolor(WHITE); cprint("Lan di chuyen thu: ");
textcolor(YELLOW+BLINK); cprintf("%4d",sl_chuyen);
for(y=y1;y>=4;y--)
{
di_chuyen(x1,y,k);
}
if(x1<x2)
for(x=x1;x<=x2;x++)
{
di_chuyen(x,4,k);
}
else
for(x=x1;x>=x2;x--)
{
di_chuyen(x,4,k);
}
for(y=4;y<=y2;y++)
{
di_chuyen(x2,y,k);
}
taokhoi(x2,y2,k);
}
void chuyen_thap(int x1,int y1,int x2,int y2,int x3,int y3,int m)
{
if(m<1) return;
else if(m==1)
chuyen_khoi(x1,y1,x2,y2,1);
else
{
chuyen_thap(x1,y1-1,x3,y3,x2,y2,m-1);
chuyen_khoi(x1,y1,x2,y2,m);
chuyen_thap(x3,y3,x2,y2-1,x1,y1,m-1);
}
}
main()
{
int m;
int x1,y1,x2,y2,x3,y3;
x1=13; x2=40; x3=67; y1=y2=y3=24;
textmode(C80); clrscr();
printf("So tang cua thap m (1<m<13):");
scanf("%d",&m); if(m<2||m>12) exit(1);
printf("\nToc do di chuyen t (0<t<100): ");
scanf("%d",&t);
textbackground(mau_nen); clrscr();
dung_thap(x1,y1,m); getch();
chuyen_thap(x1,y1,x2,y2,x3,y3,m);
getch();
window(1,1,80,25);
textbacground(mau_nen);
textcolor(WHITE); clrscr();
system("cls");
}
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?