Chú ý: Xoắn ốc theo chiều xuống, phải, lên trái.
#include<stdio.h>
#include<conio.h>
#define ROW 12
#define COL 12
void Nhapmn(int &m, int &n)
{
do
{
printf("\nNhap hang: ");
scanf("%d", &m);
printf("\nNhap cot: ");
scanf("%d", &n);
} while ((m < 1 || m>12) && (n<1 || n > 12));
}
void MakeSpiral(int a[ROW][COL], int m, int n)
{
int maxhang, maxcot, minhang, mincot, hang, cot;
int check = 0;
maxhang = m - 1;
maxcot = n - 1;
minhang = mincot = 0;
hang = cot = 0;
for (int i = 0; i < m*n; i++)
{
a[hang][cot] = i + 1;
switch (check)
{
case 0:
if (hang < maxhang)
hang++;
else
{
mincot++;
cot++;
check++;
}
break;
case 1:
if (cot < maxcot)
cot++;
else
{
maxhang--;
hang--;
check++;
}
break;
case 2:
if (hang>minhang)
hang--;
else
{
maxcot--;
cot--;
check++;
}
break;
case 3:
if (cot > mincot)
cot--;
else
{
minhang++;
hang++;
check = 0;
}
break;
}
}
}
void xuat(int a[ROW][COL], int m, int n)
{
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
printf("\t%d", a[i][j]);
printf("\n");
}
}
void main()
{
int a[ROW][COL], m, n;
Nhapmn(m, n);
MakeSpiral(a, m, n);
xuat(a, m, n);
getch();
}
IT - Công Nghệ Thông Tin
Thứ Sáu, 5 tháng 2, 2016
Thứ Ba, 2 tháng 2, 2016
Thứ Sáu, 29 tháng 1, 2016
Cách sử dụng hàm gotoxy() trong Visual Studio
Hiện tại trong Visual Studio có những hàm của Borland C không thể sử dụng được bởi vì nó quá cũ, không được hỗ trợ trong các thư viện chuẩn của VS nữa, trong đó gotoxy(). Các bạn chỉ cần khai báo thư viện:
#include<windows.h>
Và sau đó thêm cái hàm này vào:
void gotoxy(short x, short y)
{
HANDLE hConsoleOutput;
COORD Cursor_an_Pos = { x, y };
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput, Cursor_an_Pos);
}
Rồi các bạn sử dụng hàm gotoxy() bình thường :D
#include<windows.h>
Và sau đó thêm cái hàm này vào:
void gotoxy(short x, short y)
{
HANDLE hConsoleOutput;
COORD Cursor_an_Pos = { x, y };
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput, Cursor_an_Pos);
}
Rồi các bạn sử dụng hàm gotoxy() bình thường :D
Thứ Ba, 26 tháng 1, 2016
Cách gõ tiếng việt trong Borland C
Hướng dẫn sau đây chỉ hoạt động được trên Borland C hoặc Turbo C nền Dos, tức là phải chạy thông qua phần mềm giả lập DosBox mình có up ở dưới, vì nếu các bạn chạy BC trên win 7, 8, 10 thì font chữ sẽ bị lỗi và không chạy được trên Visual Studio hay các phần mềm build code C khác nhé !
Trước hết, phải khai báo thư viện dos.h để có thể chạy được.
#include<dos.h>
Sau đó các bạn copy hàm này vào bài code của bạn, nên để nó sau phần khai báo thư viện để mặc định luôn cho dễ làm.
void tiengviet(void)
{
int i, j;
char vnfont[16*256]={
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
24,24,24,24,24,24,24,248,0,0,0,0,0,0,0,0,
240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,
0,254,2,3,63,3,3,3,3,3,3,3,255,255,0,0,
0,254,254,254,254,126,62,30,14,6,254,254,254,254,254,0,
255,1,1,1,1,1,1,249,249,1,1,1,1,1,1,255,
0,0,0,0,0,0,24,60,60,24,0,0,0,0,0,0,
0,255,0,0,0,0,0,0,0,0,0,0,255,255,0,0,
0,254,254,126,62,30,14,6,126,126,126,126,126,254,254,0,
0,254,254,126,126,126,126,126,6,14,30,62,126,254,254,0,
0,0,248,4,254,2,3,3,3,3,3,3,255,255,0,0,
255,128,129,131,135,143,159,191,131,131,131,131,131,128,128,255,
0,254,2,3,3,255,3,3,3,3,3,3,255,255,0,0,
0,254,2,115,131,131,131,115,3,3,3,3,255,255,0,0,
0,254,2,3,195,67,251,67,195,3,3,3,255,255,0,0,
0,0,64,96,112,120,124,126,124,120,112,96,64,0,0,0,
0,0,1,3,7,15,31,63,31,15,7,3,1,0,0,0,
0,254,2,243,139,243,147,139,3,3,3,3,255,255,0,0,
0,254,2,251,131,243,131,251,3,3,3,3,255,255,0,0,
255,1,125,125,171,215,239,239,239,215,187,109,85,41,1,255,
0,254,130,130,130,84,40,16,16,40,68,130,170,214,254,0,
0,0,0,0,0,0,0,255,24,24,24,24,24,24,24,24,
0,1,3,2,6,4,12,136,216,80,112,32,0,0,0,0,
0,0,0,0,8,28,62,127,28,28,28,28,0,0,0,0,
0,0,0,0,28,28,28,28,127,62,28,8,0,0,0,0,
0,0,0,0,0,0,24,12,254,12,24,0,0,0,0,0,
0,0,0,0,0,0,48,96,254,96,48,0,0,0,0,0,
0,127,126,124,127,111,79,0,0,79,111,127,124,126,127,0,
0,126,62,30,126,118,114,0,0,114,118,126,30,62,126,0,
0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,24,60,60,60,24,24,0,24,24,0,0,0,
0,0,0,102,102,102,36,0,0,0,0,0,0,0,0,0,
0,0,0,0,108,108,254,108,108,108,254,108,108,0,0,0,
0,0,24,24,124,198,194,192,124,6,134,198,124,24,24,0,
0,0,0,0,0,0,194,198,12,24,48,102,198,0,0,0,
0,0,0,0,56,108,108,56,118,220,204,204,118,0,0,0,
0,0,0,48,48,48,96,0,0,0,0,0,0,0,0,0,
0,0,0,0,12,24,48,48,48,48,48,24,12,0,0,0,
0,0,0,0,48,24,12,12,12,12,12,24,48,0,0,0,
0,0,0,0,0,0,102,60,255,60,102,0,0,0,0,0,
0,0,0,0,0,0,24,24,126,24,24,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,24,24,24,48,0,0,
0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,24,24,0,0,0,
0,0,0,0,2,6,12,24,48,96,192,128,0,0,0,0,
0,0,0,0,124,198,206,222,246,230,198,198,124,0,0,0,
0,0,0,0,24,56,120,24,24,24,24,24,126,0,0,0,
0,0,0,0,124,198,6,12,24,48,96,198,254,0,0,0,
0,0,0,0,124,198,6,6,60,6,6,198,124,0,0,0,
0,0,0,0,12,28,60,108,204,254,12,12,30,0,0,0,
0,0,0,0,254,192,192,192,252,6,6,198,124,0,0,0,
0,0,0,0,60,96,192,192,252,198,198,198,124,0,0,0,
0,0,0,0,254,198,6,12,24,48,48,48,48,0,0,0,
0,0,0,0,124,198,198,198,124,198,198,198,124,0,0,0,
0,0,0,0,124,198,198,198,126,6,6,12,120,0,0,0,
0,0,0,0,0,24,24,0,0,0,24,24,0,0,0,0,
0,0,0,0,0,24,24,0,0,0,24,24,48,0,0,0,
0,0,0,0,6,12,24,48,96,48,24,12,6,0,0,0,
0,0,0,0,0,0,0,126,0,0,126,0,0,0,0,0,
0,0,0,0,96,48,24,12,6,12,24,48,96,0,0,0,
0,0,0,0,124,198,198,12,24,24,0,24,24,0,0,0,
0,0,0,0,124,198,198,222,222,222,220,192,124,0,0,0,
0,0,0,0,16,56,108,198,198,254,198,198,198,0,0,0,
0,0,0,0,252,102,102,102,124,102,102,102,252,0,0,0,
0,0,0,0,60,102,194,192,192,192,194,102,60,0,0,0,
0,0,0,0,248,108,102,102,102,102,102,108,248,0,0,0,
0,0,0,0,254,102,98,104,120,104,98,102,254,0,0,0,
0,0,0,0,254,102,98,104,120,104,96,96,240,0,0,0,
0,0,0,0,60,102,194,192,192,222,198,102,58,0,0,0,
0,0,0,0,198,198,198,198,254,198,198,198,198,0,0,0,
0,0,0,0,60,24,24,24,24,24,24,24,60,0,0,0,
0,0,0,0,30,12,12,12,12,12,204,204,120,0,0,0,
0,0,0,0,230,102,108,108,120,108,108,102,230,0,0,0,
0,0,0,0,240,96,96,96,96,96,98,102,254,0,0,0,
0,0,0,0,198,238,254,254,214,198,198,198,198,0,0,0,
0,0,0,0,198,230,246,254,222,206,198,198,198,0,0,0,
0,0,0,0,56,108,198,198,198,198,198,108,56,0,0,0,
0,0,0,0,252,102,102,102,124,96,96,96,240,0,0,0,
0,0,0,0,124,198,198,198,198,214,222,124,12,14,0,0,
0,0,0,0,252,102,102,102,124,108,102,102,231,0,0,0,
0,0,0,0,124,198,198,96,56,12,198,198,124,0,0,0,
0,0,0,0,126,126,90,24,24,24,24,24,60,0,0,0,
0,0,0,0,198,198,198,198,198,198,198,198,124,0,0,0,
0,0,0,0,198,198,198,198,198,198,108,56,16,0,0,0,
0,0,0,0,198,198,198,198,214,214,254,124,108,0,0,0,
0,0,0,0,198,198,108,56,56,56,108,198,198,0,0,0,
0,0,0,0,102,102,102,102,60,24,24,24,60,0,0,0,
0,0,0,0,254,198,140,24,48,96,194,198,254,0,0,0,
0,0,0,0,60,48,48,48,48,48,48,48,60,0,0,0,
0,0,0,0,128,192,224,112,56,28,14,6,2,0,0,0,
0,0,0,0,60,12,12,12,12,12,12,12,60,0,0,0,
0,0,16,56,108,198,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,
0,0,48,48,24,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,120,12,124,204,204,118,0,0,0,
0,0,0,0,224,96,96,120,108,102,102,102,124,0,0,0,
0,0,0,0,0,0,0,124,198,192,192,198,124,0,0,0,
0,0,0,0,28,12,12,60,108,204,204,204,118,0,0,0,
0,0,0,0,0,0,0,124,198,254,192,198,124,0,0,0,
0,0,0,0,56,108,100,96,240,96,96,96,240,0,0,0,
0,0,0,0,0,0,0,118,204,204,204,124,12,204,120,0,
0,0,0,0,224,96,96,108,118,102,102,102,230,0,0,0,
0,0,0,0,24,24,0,56,24,24,24,24,60,0,0,0,
0,0,0,0,6,6,0,14,6,6,6,6,102,102,60,0,
0,0,0,0,224,96,96,102,108,120,108,102,230,0,0,0,
0,0,0,0,56,24,24,24,24,24,24,24,60,0,0,0,
0,0,0,0,0,0,0,236,254,214,214,214,198,0,0,0,
0,0,0,0,0,0,0,220,102,102,102,102,102,0,0,0,
0,0,0,0,0,0,0,124,198,198,198,198,124,0,0,0,
0,0,0,0,0,0,0,220,102,102,102,124,96,96,240,0,
0,0,0,0,0,0,0,118,204,204,204,124,12,12,30,0,
0,0,0,0,0,0,0,220,118,102,96,96,240,0,0,0,
0,0,0,0,0,0,0,124,198,112,28,198,124,0,0,0,
0,0,0,0,16,48,48,252,48,48,48,54,28,0,0,0,
0,0,0,0,0,0,0,204,204,204,204,204,118,0,0,0,
0,0,0,0,0,0,0,102,102,102,102,60,24,0,0,0,
0,0,0,0,0,0,0,198,198,214,214,254,108,0,0,0,
0,0,0,0,0,0,0,198,108,56,56,108,198,0,0,0,
0,0,0,0,0,0,0,198,198,198,198,126,6,12,248,0,
0,0,0,0,0,0,0,254,204,24,48,102,254,0,0,0,
0,0,0,0,14,24,24,24,112,24,24,24,14,0,0,0,
0,0,0,0,24,24,24,24,0,24,24,24,24,0,0,0,
0,0,0,0,112,24,24,24,14,24,24,24,112,0,0,0,
0,0,0,0,118,220,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,16,56,108,198,198,254,0,0,0,0,
0,0,0,0,0,0,124,198,192,192,198,124,24,12,248,0,
0,0,0,0,204,204,0,204,204,204,204,204,118,0,0,0,
0,0,0,0,108,108,0,120,12,124,204,204,118,0,0,0,
0,0,48,72,72,48,0,120,12,124,204,204,118,0,0,0,
0,0,0,0,108,108,0,124,198,254,192,198,124,0,0,0,
0,0,0,0,108,108,0,56,24,24,24,24,60,0,0,0,
0,0,0,24,60,102,0,56,24,24,24,24,60,0,0,0,
0,0,0,0,108,222,26,26,126,216,216,218,108,0,0,0,
0,0,0,0,204,204,0,124,198,198,198,198,124,0,0,0,
0,0,0,48,120,204,0,204,204,204,204,204,118,0,0,0,
0,0,0,0,198,198,0,198,198,198,198,126,6,12,120,0,
0,0,24,24,24,124,198,192,192,198,124,24,24,24,0,0,
0,0,0,56,108,100,96,240,96,96,102,230,188,0,0,0,
0,0,0,102,102,102,60,24,126,24,60,24,24,0,0,0,
0,0,0,252,102,102,124,98,102,111,102,102,243,0,0,0,
0,0,0,0,118,220,0,220,102,102,102,102,102,0,0,0,
0,0,0,0,0,0,54,108,216,108,54,0,0,0,0,0,
0,0,0,0,0,0,216,108,54,108,216,0,0,0,0,0,
0,0,0,0,24,24,24,126,24,24,24,0,126,126,0,0,
0,0,0,0,96,48,24,12,24,48,96,0,124,124,0,0,
0,0,0,0,12,24,48,96,48,24,12,0,124,124,0,0,
24,24,24,60,60,126,126,255,24,24,24,24,24,24,24,24,
24,24,24,24,24,24,24,24,255,126,126,60,60,24,24,24,
0,0,0,0,0,64,112,124,255,124,112,64,0,0,0,0,
0,0,0,0,0,2,14,62,255,62,14,2,0,0,0,0,
0,224,32,48,48,48,48,48,48,48,48,48,240,240,0,0,
255,128,128,128,128,128,128,159,159,128,128,128,128,128,128,255,
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,240,24,28,30,30,3,3,3,3,3,3,255,255,0,0,
0,254,1,0,124,254,254,254,254,124,0,1,254,0,0,0,
0,0,0,128,128,64,64,64,64,128,128,0,0,0,0,0,
0,0,0,0,0,0,0,255,192,192,192,192,192,192,192,192,
0,0,108,56,0,56,108,198,198,254,198,198,198,0,0,0,
0,16,56,108,0,56,108,198,198,254,198,198,198,0,0,0,
0,16,56,68,254,102,98,104,120,104,98,102,254,0,0,0,
0,16,56,68,56,108,198,198,198,198,198,108,56,0,0,0,
0,0,3,1,58,108,198,198,198,198,198,108,56,0,0,0,
0,0,3,1,199,198,198,198,198,198,198,198,124,0,0,0,
0,0,0,0,248,108,102,102,254,102,102,108,248,0,0,0,
0,0,0,0,108,56,0,120,12,124,204,204,118,0,0,0,
0,0,0,0,56,108,0,120,12,124,204,204,118,0,0,0,
0,0,0,0,56,108,0,124,198,254,192,198,124,0,0,0,
0,0,0,0,56,108,0,124,198,198,198,198,124,0,0,0,
0,0,0,0,0,3,1,126,198,198,198,198,124,0,0,0,
0,0,0,0,0,3,1,206,204,204,204,204,118,0,0,0,
0,0,0,0,12,62,12,60,108,204,204,204,118,0,0,0,
0,224,96,112,112,112,112,112,112,112,112,112,240,240,0,0,
0,255,0,0,0,0,0,0,0,0,0,0,255,255,0,0,
0,255,192,192,195,194,223,194,195,192,192,192,255,63,0,0,
0,255,192,192,192,192,192,192,192,192,192,192,255,63,0,0,
24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
255,255,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
0,0,192,96,48,0,0,120,12,124,204,204,118,0,0,0,
0,0,56,8,16,0,0,120,12,124,204,204,118,0,0,0,
0,0,0,118,220,0,0,120,12,124,204,204,118,0,0,0,
0,0,6,12,24,0,0,120,12,124,204,204,118,0,0,0,
0,0,0,0,0,0,0,120,12,124,204,204,118,0,48,48,
54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,
0,0,96,16,76,56,0,120,12,124,204,204,118,0,0,0,
0,0,7,1,110,56,0,120,12,124,204,204,118,0,0,0,
0,0,118,220,108,56,0,120,12,124,204,204,118,0,0,0,
0,0,12,16,108,56,0,120,12,124,204,204,118,0,0,0,
0,0,0,0,0,0,0,248,24,24,24,24,24,24,24,24,
255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,255,
255,255,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
0,7,6,6,6,6,6,6,6,6,6,6,7,1,0,0,
0,255,0,6,6,12,12,152,216,240,112,0,255,255,0,0,
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,255,
0,0,0,0,108,56,0,120,12,124,204,204,118,0,48,48,
0,0,192,96,56,108,0,120,12,124,204,204,118,0,0,0,
0,0,7,1,58,108,0,120,12,124,204,204,118,0,0,0,
0,0,118,220,56,108,0,120,12,124,204,204,118,0,0,0,
0,0,6,12,56,108,0,120,12,124,204,204,118,0,0,0,
0,0,0,0,56,108,0,120,12,124,204,204,118,0,48,48,
0,0,192,96,48,0,0,124,198,254,192,198,124,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,
0,0,56,8,16,0,0,124,198,254,192,198,124,0,0,0,
0,0,0,118,220,0,0,124,198,254,192,198,124,0,0,0,
0,0,6,12,24,0,0,124,198,254,192,198,124,0,0,0,
0,0,0,0,0,0,0,124,198,254,192,198,124,0,24,24,
0,48,24,12,56,108,0,124,198,254,192,198,124,0,0,0,
0,0,7,1,58,108,0,124,198,254,192,198,124,0,0,0,
0,0,118,220,56,108,0,124,198,254,192,198,124,0,0,0,
0,0,6,12,56,108,0,124,198,254,192,198,124,0,0,0,
0,0,0,0,56,108,0,124,198,254,192,198,124,0,24,24,
0,0,192,96,48,0,0,56,24,24,24,24,60,0,0,0,
0,0,56,8,16,0,0,56,24,24,24,24,60,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
255,255,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
255,128,128,128,128,128,128,159,159,128,128,128,128,128,128,255,
0,0,0,118,220,0,0,56,24,24,24,24,60,0,0,0,
0,0,6,12,24,0,0,56,24,24,24,24,60,0,0,0,
0,0,0,0,24,24,0,56,24,24,24,24,60,0,24,24,
0,0,192,96,48,0,0,124,198,198,198,198,124,0,0,0,
0,0,0,0,62,96,192,192,254,192,192,96,62,0,0,0,
0,0,56,8,16,0,0,124,198,198,198,198,124,0,0,0,
0,0,118,220,0,0,0,124,198,198,198,198,124,0,0,0,
0,0,6,12,24,0,0,124,198,198,198,198,124,0,0,0,
0,0,0,0,0,0,0,124,198,198,198,198,124,0,24,24,
0,0,192,96,56,108,0,124,198,198,198,198,124,0,0,0,
0,0,7,1,58,108,0,124,198,198,198,198,124,0,0,0,
0,0,118,220,56,108,0,124,198,198,198,198,124,0,0,0,
0,0,6,12,56,108,0,124,198,198,198,198,124,0,0,0,
0,0,0,0,56,108,0,124,198,198,198,198,124,0,24,24,
0,0,192,96,48,3,1,126,198,198,198,198,124,0,0,0,
0,0,56,8,16,3,1,126,198,198,198,198,124,0,0,0,
0,0,118,220,0,3,1,126,198,198,198,198,124,0,0,0,
0,0,6,12,24,3,1,126,198,198,198,198,124,0,0,0,
0,0,0,0,0,3,1,126,198,198,198,198,124,0,24,24,
0,0,192,96,48,0,0,204,204,204,204,204,118,0,0,0,
0,0,0,0,0,254,0,0,254,0,0,254,0,0,0,0,
0,0,56,8,16,0,0,204,204,204,204,204,118,0,0,0,
0,0,118,220,0,0,0,204,204,204,204,204,118,0,0,0,
0,0,6,12,24,0,0,204,204,204,204,204,118,0,0,0,
0,0,0,0,0,0,0,204,204,204,204,204,118,0,48,48,
0,0,192,96,48,3,1,206,204,204,204,204,118,0,0,0,
0,0,56,8,16,3,1,206,204,204,204,204,118,0,0,0,
0,0,118,220,0,3,1,206,204,204,204,204,118,0,0,0,
0,0,6,12,24,3,1,206,204,204,204,204,118,0,0,0,
0,0,0,0,0,3,1,206,204,204,204,204,118,0,48,48,
0,0,192,96,48,0,0,198,198,198,198,126,6,12,248,0,
0,0,56,8,16,0,0,198,198,198,198,126,6,12,248,0,
0,0,0,118,220,0,0,198,198,198,198,126,6,12,248,0,
0,0,6,12,24,0,0,198,198,198,198,126,6,12,248,0,
0,0,0,0,0,0,0,198,198,198,198,126,4,12,251,3,
0,254,1,0,0,0,0,0,0,0,0,1,254,0,0,0
};
textmode(C80);
asm{
cli
mov dx,0x3c4
mov ax,0x100
out dx,ax
mov ax,0x402
out dx,ax
mov ax,0x704
out dx,ax
mov ax,0x300
out dx,ax
mov dx,0x3ce
mov ax,0x204
out dx,ax
mov ax,0x5
out dx,ax
mov ax,0x406
out dx,ax
}
for(i=0;i<256;++i)
for(j=0;j<16;++j)
pokeb(0xa000, i*32+j, vnfont[i*16+j]);
asm{
mov dx,0x3c4
mov ax,0x100
out dx,ax
mov ax,0x302
out dx,ax
mov ax,0x304
out dx,ax
mov ax,0x300
out dx,ax
mov dx,0x3ce
mov ax,0x4
out dx,ax
mov ax,0x1005
out dx,ax
mov ax,0xe06
out dx,ax
cli
}
}
Trước hết, phải khai báo thư viện dos.h để có thể chạy được.
#include<dos.h>
Sau đó các bạn copy hàm này vào bài code của bạn, nên để nó sau phần khai báo thư viện để mặc định luôn cho dễ làm.
void tiengviet(void)
{
int i, j;
char vnfont[16*256]={
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
24,24,24,24,24,24,24,248,0,0,0,0,0,0,0,0,
240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,240,
255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,
0,254,2,3,63,3,3,3,3,3,3,3,255,255,0,0,
0,254,254,254,254,126,62,30,14,6,254,254,254,254,254,0,
255,1,1,1,1,1,1,249,249,1,1,1,1,1,1,255,
0,0,0,0,0,0,24,60,60,24,0,0,0,0,0,0,
0,255,0,0,0,0,0,0,0,0,0,0,255,255,0,0,
0,254,254,126,62,30,14,6,126,126,126,126,126,254,254,0,
0,254,254,126,126,126,126,126,6,14,30,62,126,254,254,0,
0,0,248,4,254,2,3,3,3,3,3,3,255,255,0,0,
255,128,129,131,135,143,159,191,131,131,131,131,131,128,128,255,
0,254,2,3,3,255,3,3,3,3,3,3,255,255,0,0,
0,254,2,115,131,131,131,115,3,3,3,3,255,255,0,0,
0,254,2,3,195,67,251,67,195,3,3,3,255,255,0,0,
0,0,64,96,112,120,124,126,124,120,112,96,64,0,0,0,
0,0,1,3,7,15,31,63,31,15,7,3,1,0,0,0,
0,254,2,243,139,243,147,139,3,3,3,3,255,255,0,0,
0,254,2,251,131,243,131,251,3,3,3,3,255,255,0,0,
255,1,125,125,171,215,239,239,239,215,187,109,85,41,1,255,
0,254,130,130,130,84,40,16,16,40,68,130,170,214,254,0,
0,0,0,0,0,0,0,255,24,24,24,24,24,24,24,24,
0,1,3,2,6,4,12,136,216,80,112,32,0,0,0,0,
0,0,0,0,8,28,62,127,28,28,28,28,0,0,0,0,
0,0,0,0,28,28,28,28,127,62,28,8,0,0,0,0,
0,0,0,0,0,0,24,12,254,12,24,0,0,0,0,0,
0,0,0,0,0,0,48,96,254,96,48,0,0,0,0,0,
0,127,126,124,127,111,79,0,0,79,111,127,124,126,127,0,
0,126,62,30,126,118,114,0,0,114,118,126,30,62,126,0,
0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,24,60,60,60,24,24,0,24,24,0,0,0,
0,0,0,102,102,102,36,0,0,0,0,0,0,0,0,0,
0,0,0,0,108,108,254,108,108,108,254,108,108,0,0,0,
0,0,24,24,124,198,194,192,124,6,134,198,124,24,24,0,
0,0,0,0,0,0,194,198,12,24,48,102,198,0,0,0,
0,0,0,0,56,108,108,56,118,220,204,204,118,0,0,0,
0,0,0,48,48,48,96,0,0,0,0,0,0,0,0,0,
0,0,0,0,12,24,48,48,48,48,48,24,12,0,0,0,
0,0,0,0,48,24,12,12,12,12,12,24,48,0,0,0,
0,0,0,0,0,0,102,60,255,60,102,0,0,0,0,0,
0,0,0,0,0,0,24,24,126,24,24,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,24,24,24,48,0,0,
0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,24,24,0,0,0,
0,0,0,0,2,6,12,24,48,96,192,128,0,0,0,0,
0,0,0,0,124,198,206,222,246,230,198,198,124,0,0,0,
0,0,0,0,24,56,120,24,24,24,24,24,126,0,0,0,
0,0,0,0,124,198,6,12,24,48,96,198,254,0,0,0,
0,0,0,0,124,198,6,6,60,6,6,198,124,0,0,0,
0,0,0,0,12,28,60,108,204,254,12,12,30,0,0,0,
0,0,0,0,254,192,192,192,252,6,6,198,124,0,0,0,
0,0,0,0,60,96,192,192,252,198,198,198,124,0,0,0,
0,0,0,0,254,198,6,12,24,48,48,48,48,0,0,0,
0,0,0,0,124,198,198,198,124,198,198,198,124,0,0,0,
0,0,0,0,124,198,198,198,126,6,6,12,120,0,0,0,
0,0,0,0,0,24,24,0,0,0,24,24,0,0,0,0,
0,0,0,0,0,24,24,0,0,0,24,24,48,0,0,0,
0,0,0,0,6,12,24,48,96,48,24,12,6,0,0,0,
0,0,0,0,0,0,0,126,0,0,126,0,0,0,0,0,
0,0,0,0,96,48,24,12,6,12,24,48,96,0,0,0,
0,0,0,0,124,198,198,12,24,24,0,24,24,0,0,0,
0,0,0,0,124,198,198,222,222,222,220,192,124,0,0,0,
0,0,0,0,16,56,108,198,198,254,198,198,198,0,0,0,
0,0,0,0,252,102,102,102,124,102,102,102,252,0,0,0,
0,0,0,0,60,102,194,192,192,192,194,102,60,0,0,0,
0,0,0,0,248,108,102,102,102,102,102,108,248,0,0,0,
0,0,0,0,254,102,98,104,120,104,98,102,254,0,0,0,
0,0,0,0,254,102,98,104,120,104,96,96,240,0,0,0,
0,0,0,0,60,102,194,192,192,222,198,102,58,0,0,0,
0,0,0,0,198,198,198,198,254,198,198,198,198,0,0,0,
0,0,0,0,60,24,24,24,24,24,24,24,60,0,0,0,
0,0,0,0,30,12,12,12,12,12,204,204,120,0,0,0,
0,0,0,0,230,102,108,108,120,108,108,102,230,0,0,0,
0,0,0,0,240,96,96,96,96,96,98,102,254,0,0,0,
0,0,0,0,198,238,254,254,214,198,198,198,198,0,0,0,
0,0,0,0,198,230,246,254,222,206,198,198,198,0,0,0,
0,0,0,0,56,108,198,198,198,198,198,108,56,0,0,0,
0,0,0,0,252,102,102,102,124,96,96,96,240,0,0,0,
0,0,0,0,124,198,198,198,198,214,222,124,12,14,0,0,
0,0,0,0,252,102,102,102,124,108,102,102,231,0,0,0,
0,0,0,0,124,198,198,96,56,12,198,198,124,0,0,0,
0,0,0,0,126,126,90,24,24,24,24,24,60,0,0,0,
0,0,0,0,198,198,198,198,198,198,198,198,124,0,0,0,
0,0,0,0,198,198,198,198,198,198,108,56,16,0,0,0,
0,0,0,0,198,198,198,198,214,214,254,124,108,0,0,0,
0,0,0,0,198,198,108,56,56,56,108,198,198,0,0,0,
0,0,0,0,102,102,102,102,60,24,24,24,60,0,0,0,
0,0,0,0,254,198,140,24,48,96,194,198,254,0,0,0,
0,0,0,0,60,48,48,48,48,48,48,48,60,0,0,0,
0,0,0,0,128,192,224,112,56,28,14,6,2,0,0,0,
0,0,0,0,60,12,12,12,12,12,12,12,60,0,0,0,
0,0,16,56,108,198,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,
0,0,48,48,24,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,120,12,124,204,204,118,0,0,0,
0,0,0,0,224,96,96,120,108,102,102,102,124,0,0,0,
0,0,0,0,0,0,0,124,198,192,192,198,124,0,0,0,
0,0,0,0,28,12,12,60,108,204,204,204,118,0,0,0,
0,0,0,0,0,0,0,124,198,254,192,198,124,0,0,0,
0,0,0,0,56,108,100,96,240,96,96,96,240,0,0,0,
0,0,0,0,0,0,0,118,204,204,204,124,12,204,120,0,
0,0,0,0,224,96,96,108,118,102,102,102,230,0,0,0,
0,0,0,0,24,24,0,56,24,24,24,24,60,0,0,0,
0,0,0,0,6,6,0,14,6,6,6,6,102,102,60,0,
0,0,0,0,224,96,96,102,108,120,108,102,230,0,0,0,
0,0,0,0,56,24,24,24,24,24,24,24,60,0,0,0,
0,0,0,0,0,0,0,236,254,214,214,214,198,0,0,0,
0,0,0,0,0,0,0,220,102,102,102,102,102,0,0,0,
0,0,0,0,0,0,0,124,198,198,198,198,124,0,0,0,
0,0,0,0,0,0,0,220,102,102,102,124,96,96,240,0,
0,0,0,0,0,0,0,118,204,204,204,124,12,12,30,0,
0,0,0,0,0,0,0,220,118,102,96,96,240,0,0,0,
0,0,0,0,0,0,0,124,198,112,28,198,124,0,0,0,
0,0,0,0,16,48,48,252,48,48,48,54,28,0,0,0,
0,0,0,0,0,0,0,204,204,204,204,204,118,0,0,0,
0,0,0,0,0,0,0,102,102,102,102,60,24,0,0,0,
0,0,0,0,0,0,0,198,198,214,214,254,108,0,0,0,
0,0,0,0,0,0,0,198,108,56,56,108,198,0,0,0,
0,0,0,0,0,0,0,198,198,198,198,126,6,12,248,0,
0,0,0,0,0,0,0,254,204,24,48,102,254,0,0,0,
0,0,0,0,14,24,24,24,112,24,24,24,14,0,0,0,
0,0,0,0,24,24,24,24,0,24,24,24,24,0,0,0,
0,0,0,0,112,24,24,24,14,24,24,24,112,0,0,0,
0,0,0,0,118,220,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,16,56,108,198,198,254,0,0,0,0,
0,0,0,0,0,0,124,198,192,192,198,124,24,12,248,0,
0,0,0,0,204,204,0,204,204,204,204,204,118,0,0,0,
0,0,0,0,108,108,0,120,12,124,204,204,118,0,0,0,
0,0,48,72,72,48,0,120,12,124,204,204,118,0,0,0,
0,0,0,0,108,108,0,124,198,254,192,198,124,0,0,0,
0,0,0,0,108,108,0,56,24,24,24,24,60,0,0,0,
0,0,0,24,60,102,0,56,24,24,24,24,60,0,0,0,
0,0,0,0,108,222,26,26,126,216,216,218,108,0,0,0,
0,0,0,0,204,204,0,124,198,198,198,198,124,0,0,0,
0,0,0,48,120,204,0,204,204,204,204,204,118,0,0,0,
0,0,0,0,198,198,0,198,198,198,198,126,6,12,120,0,
0,0,24,24,24,124,198,192,192,198,124,24,24,24,0,0,
0,0,0,56,108,100,96,240,96,96,102,230,188,0,0,0,
0,0,0,102,102,102,60,24,126,24,60,24,24,0,0,0,
0,0,0,252,102,102,124,98,102,111,102,102,243,0,0,0,
0,0,0,0,118,220,0,220,102,102,102,102,102,0,0,0,
0,0,0,0,0,0,54,108,216,108,54,0,0,0,0,0,
0,0,0,0,0,0,216,108,54,108,216,0,0,0,0,0,
0,0,0,0,24,24,24,126,24,24,24,0,126,126,0,0,
0,0,0,0,96,48,24,12,24,48,96,0,124,124,0,0,
0,0,0,0,12,24,48,96,48,24,12,0,124,124,0,0,
24,24,24,60,60,126,126,255,24,24,24,24,24,24,24,24,
24,24,24,24,24,24,24,24,255,126,126,60,60,24,24,24,
0,0,0,0,0,64,112,124,255,124,112,64,0,0,0,0,
0,0,0,0,0,2,14,62,255,62,14,2,0,0,0,0,
0,224,32,48,48,48,48,48,48,48,48,48,240,240,0,0,
255,128,128,128,128,128,128,159,159,128,128,128,128,128,128,255,
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,240,24,28,30,30,3,3,3,3,3,3,255,255,0,0,
0,254,1,0,124,254,254,254,254,124,0,1,254,0,0,0,
0,0,0,128,128,64,64,64,64,128,128,0,0,0,0,0,
0,0,0,0,0,0,0,255,192,192,192,192,192,192,192,192,
0,0,108,56,0,56,108,198,198,254,198,198,198,0,0,0,
0,16,56,108,0,56,108,198,198,254,198,198,198,0,0,0,
0,16,56,68,254,102,98,104,120,104,98,102,254,0,0,0,
0,16,56,68,56,108,198,198,198,198,198,108,56,0,0,0,
0,0,3,1,58,108,198,198,198,198,198,108,56,0,0,0,
0,0,3,1,199,198,198,198,198,198,198,198,124,0,0,0,
0,0,0,0,248,108,102,102,254,102,102,108,248,0,0,0,
0,0,0,0,108,56,0,120,12,124,204,204,118,0,0,0,
0,0,0,0,56,108,0,120,12,124,204,204,118,0,0,0,
0,0,0,0,56,108,0,124,198,254,192,198,124,0,0,0,
0,0,0,0,56,108,0,124,198,198,198,198,124,0,0,0,
0,0,0,0,0,3,1,126,198,198,198,198,124,0,0,0,
0,0,0,0,0,3,1,206,204,204,204,204,118,0,0,0,
0,0,0,0,12,62,12,60,108,204,204,204,118,0,0,0,
0,224,96,112,112,112,112,112,112,112,112,112,240,240,0,0,
0,255,0,0,0,0,0,0,0,0,0,0,255,255,0,0,
0,255,192,192,195,194,223,194,195,192,192,192,255,63,0,0,
0,255,192,192,192,192,192,192,192,192,192,192,255,63,0,0,
24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
255,255,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
0,0,192,96,48,0,0,120,12,124,204,204,118,0,0,0,
0,0,56,8,16,0,0,120,12,124,204,204,118,0,0,0,
0,0,0,118,220,0,0,120,12,124,204,204,118,0,0,0,
0,0,6,12,24,0,0,120,12,124,204,204,118,0,0,0,
0,0,0,0,0,0,0,120,12,124,204,204,118,0,48,48,
54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,
0,0,96,16,76,56,0,120,12,124,204,204,118,0,0,0,
0,0,7,1,110,56,0,120,12,124,204,204,118,0,0,0,
0,0,118,220,108,56,0,120,12,124,204,204,118,0,0,0,
0,0,12,16,108,56,0,120,12,124,204,204,118,0,0,0,
0,0,0,0,0,0,0,248,24,24,24,24,24,24,24,24,
255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,255,
255,255,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
0,7,6,6,6,6,6,6,6,6,6,6,7,1,0,0,
0,255,0,6,6,12,12,152,216,240,112,0,255,255,0,0,
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,255,
0,0,0,0,108,56,0,120,12,124,204,204,118,0,48,48,
0,0,192,96,56,108,0,120,12,124,204,204,118,0,0,0,
0,0,7,1,58,108,0,120,12,124,204,204,118,0,0,0,
0,0,118,220,56,108,0,120,12,124,204,204,118,0,0,0,
0,0,6,12,56,108,0,120,12,124,204,204,118,0,0,0,
0,0,0,0,56,108,0,120,12,124,204,204,118,0,48,48,
0,0,192,96,48,0,0,124,198,254,192,198,124,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,
0,0,56,8,16,0,0,124,198,254,192,198,124,0,0,0,
0,0,0,118,220,0,0,124,198,254,192,198,124,0,0,0,
0,0,6,12,24,0,0,124,198,254,192,198,124,0,0,0,
0,0,0,0,0,0,0,124,198,254,192,198,124,0,24,24,
0,48,24,12,56,108,0,124,198,254,192,198,124,0,0,0,
0,0,7,1,58,108,0,124,198,254,192,198,124,0,0,0,
0,0,118,220,56,108,0,124,198,254,192,198,124,0,0,0,
0,0,6,12,56,108,0,124,198,254,192,198,124,0,0,0,
0,0,0,0,56,108,0,124,198,254,192,198,124,0,24,24,
0,0,192,96,48,0,0,56,24,24,24,24,60,0,0,0,
0,0,56,8,16,0,0,56,24,24,24,24,60,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
255,255,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
255,128,128,128,128,128,128,159,159,128,128,128,128,128,128,255,
0,0,0,118,220,0,0,56,24,24,24,24,60,0,0,0,
0,0,6,12,24,0,0,56,24,24,24,24,60,0,0,0,
0,0,0,0,24,24,0,56,24,24,24,24,60,0,24,24,
0,0,192,96,48,0,0,124,198,198,198,198,124,0,0,0,
0,0,0,0,62,96,192,192,254,192,192,96,62,0,0,0,
0,0,56,8,16,0,0,124,198,198,198,198,124,0,0,0,
0,0,118,220,0,0,0,124,198,198,198,198,124,0,0,0,
0,0,6,12,24,0,0,124,198,198,198,198,124,0,0,0,
0,0,0,0,0,0,0,124,198,198,198,198,124,0,24,24,
0,0,192,96,56,108,0,124,198,198,198,198,124,0,0,0,
0,0,7,1,58,108,0,124,198,198,198,198,124,0,0,0,
0,0,118,220,56,108,0,124,198,198,198,198,124,0,0,0,
0,0,6,12,56,108,0,124,198,198,198,198,124,0,0,0,
0,0,0,0,56,108,0,124,198,198,198,198,124,0,24,24,
0,0,192,96,48,3,1,126,198,198,198,198,124,0,0,0,
0,0,56,8,16,3,1,126,198,198,198,198,124,0,0,0,
0,0,118,220,0,3,1,126,198,198,198,198,124,0,0,0,
0,0,6,12,24,3,1,126,198,198,198,198,124,0,0,0,
0,0,0,0,0,3,1,126,198,198,198,198,124,0,24,24,
0,0,192,96,48,0,0,204,204,204,204,204,118,0,0,0,
0,0,0,0,0,254,0,0,254,0,0,254,0,0,0,0,
0,0,56,8,16,0,0,204,204,204,204,204,118,0,0,0,
0,0,118,220,0,0,0,204,204,204,204,204,118,0,0,0,
0,0,6,12,24,0,0,204,204,204,204,204,118,0,0,0,
0,0,0,0,0,0,0,204,204,204,204,204,118,0,48,48,
0,0,192,96,48,3,1,206,204,204,204,204,118,0,0,0,
0,0,56,8,16,3,1,206,204,204,204,204,118,0,0,0,
0,0,118,220,0,3,1,206,204,204,204,204,118,0,0,0,
0,0,6,12,24,3,1,206,204,204,204,204,118,0,0,0,
0,0,0,0,0,3,1,206,204,204,204,204,118,0,48,48,
0,0,192,96,48,0,0,198,198,198,198,126,6,12,248,0,
0,0,56,8,16,0,0,198,198,198,198,126,6,12,248,0,
0,0,0,118,220,0,0,198,198,198,198,126,6,12,248,0,
0,0,6,12,24,0,0,198,198,198,198,126,6,12,248,0,
0,0,0,0,0,0,0,198,198,198,198,126,4,12,251,3,
0,254,1,0,0,0,0,0,0,0,0,1,254,0,0,0
};
textmode(C80);
asm{
cli
mov dx,0x3c4
mov ax,0x100
out dx,ax
mov ax,0x402
out dx,ax
mov ax,0x704
out dx,ax
mov ax,0x300
out dx,ax
mov dx,0x3ce
mov ax,0x204
out dx,ax
mov ax,0x5
out dx,ax
mov ax,0x406
out dx,ax
}
for(i=0;i<256;++i)
for(j=0;j<16;++j)
pokeb(0xa000, i*32+j, vnfont[i*16+j]);
asm{
mov dx,0x3c4
mov ax,0x100
out dx,ax
mov ax,0x302
out dx,ax
mov ax,0x304
out dx,ax
mov ax,0x300
out dx,ax
mov dx,0x3ce
mov ax,0x4
out dx,ax
mov ax,0x1005
out dx,ax
mov ax,0xe06
out dx,ax
cli
}
}
Tiếp sau đó ở trong hàm main, các bạn gọi hàm tiengviet() ngay đầu tiên luôn, và khi gõ tiếng việt thì sử dung bang mã TCVN3 (ABC) nhé, sẽ hiện kiểu kí tự vớ vẩn như "«I dêi ¬I..." trong lúc soạn thảo, nhưng đừng lo, khi debug nó sẽ chuyển sang kí tự tiếng việt đọc được.
Demo:
Demo:
DosBox - Phần mềm giả lập chạy chương trình trên nền Dos
Đây là một chương trình giả lập chạy các ứng dụng trên nền dos, công dụng như thế nào thì các bạn có thể tự tìm hiểu, còn đây là mình hướng dẫn sử dụng nó để chạy Borland C, vì sao ? Đơn giản bây giờ chúng ta sử dụng hầu hết trên nền windows 7, 8, 10 và hệ thống đồ họa trên C nó chỉ tương tích đối với hđh DOS mà thôi, cho nên nếu ai chạy BC trên các win nói trên mà ko sử dụng đc hệ thống đồ họa thì đừng hỏi vì sao nữa nhé. Vì thế mình phải sử dụng DosBox để gián tiếp sử dụng nền đồ họa của C trên BC.
Link: https://www.mediafire.com/?u
9uz5la45jnndca
Link: https://www.mediafire.com/?u
9uz5la45jnndca
Hướng dẫn cách sử dung:
Cài đặt xong mở DosBox lên nó có giao diện y như dos, chỉ cần nhập các dòng lệnh cơ bản để mở BC lên sau đây, sau mỗi 1 dòng các bạn nhấn enter: (Bạn nên để thư mục BC ở ngay ổ D, hoặc ổ E tùy ý, hạn chế đừng để nó sâu quá thì dòng lệnh sẽ nhiều)
Cài đặt xong mở DosBox lên nó có giao diện y như dos, chỉ cần nhập các dòng lệnh cơ bản để mở BC lên sau đây, sau mỗi 1 dòng các bạn nhấn enter: (Bạn nên để thư mục BC ở ngay ổ D, hoặc ổ E tùy ý, hạn chế đừng để nó sâu quá thì dòng lệnh sẽ nhiều)
mount d d: (nếu là ổ E thì bạn chỉ cần thay d là e là đc)
d:
cd bc
cd bin
bc
Thứ Bảy, 2 tháng 1, 2016
Chương trình sử dụng đồ họa vẽ đồng hộ kim chạy đúng giờ hệ thống
Chỉ chạy được trên BC, sử dụng Dosbox để có thể chạy được nền độ họa !
#include<graphics.h>
#include<conio.h>
#include<math.h>
#include<dos.h>
int x0,y0,rgio,rphut,rgiay,mgio,mphut,mgiay;
unsigned phutgioht,gioht,phutht,giayht;
void ke(int ddo, unsigned dai, unsigned day, unsigned mau)
{
unsigned x,y;
float goc;
while(ddo>=360)
ddo=ddo-360;
goc=(M_PI/180)*ddo;
x=x0+(int)(dai*cos(goc)+0.5);
y=y0-(int)(dai*sin(goc)+0.5);
setcolor(mau);
setlinestyle(0,0,day);
line(x0,y0,x,y);
}
void ke_giay(unsigned giay)
{
int ddo;
ddo=(90-6*giay);
ke(ddo,rgiay,1,mgiay);
}
void ke_phut(unsigned phut)
{
int ddo;
ddo=(90-6*phut);
ke(ddo,rphut,3,mphut);
}
void ke_gio(unsigned gio, unsigned phut)
{
int ddo;
ddo=360+90-30*(gio%12)-(phut+1)/2;
ke(ddo,rgio,3,mgio);
}
void chay_kim_giay(void)
{
unsigned giay;
struct time t;
gettime(&t);
giay=t.ti_sec;
if(giay!=giayht)
{
ke_giay(giayht);
giayht=giay;
ke_giay(giayht);
}
}
void chay_kim_phut(void)
{
unsigned phut;
struct time t;
gettime(&t);
phut=t.ti_min;
if(phut!=phutht)
{
ke_phut(phutht);
phutht=phut;
ke_phut(phutht);
}
}
void chay_kim_gio(void)
{
unsigned h,gio,phut,sophut,sophutht;
struct time t;
gettime(&t);
gio=t.ti_hour;
phut=t.ti_min;
sophut=gio*60+phut;
sophutht=gioht*60+phutgioht;
if(sophut<sophutht)
sophut=sophut+12*60;
h=sophut-sophutht;
if(h>=12)
{
ke_gio(gioht,phutgioht);
phutgioht=phut;
gioht=gio;
ke_gio(gioht,phutgioht);
}
}
void main()
{
struct time t;
char *dso[]={"","12","1","2","3","4","5","6","7","8","9","10","11"};
int i, mh=0, mode, r,x,y;
float goc;
initgraph(&mh,&mode,"E:\\BC\\BGI");
x0=(getmaxx()/2)-1;
y0=(getmaxy()/2)-1;
r=y0-2;
rgiay=r-10;
rphut=r-50;
rgio=r-90;
mgiay=BROWN;
mphut=RED;
mgio=YELLOW;
setcolor(BLUE);
setlinestyle(0,0,3);
circle(x0,y0,r);
setfillstyle(1,YELLOW);
floodfill(0,0,BLUE);
setfillstyle(1,WHITE);
floodfill(x0,y0,BLUE);
setlinestyle(0,0,1);
circle(x0,y0,10);
setfillstyle(1,GREEN);
floodfill(x0,y0,BLUE);
settextjustify(1,1);
setcolor(MAGENTA);
outtextxy(x0,y0+120,"TAH-JR");
settextstyle(3,0,3);
settextjustify(1,1);
setcolor(BLUE);
for(i=1;i<=12;i++)
{
goc=(2*M_PI+M_PI/2)-(i-1)*(M_PI/6);
x=x0+(int)(rphut*cos(goc)+0.5);
y=y0-(int)(rphut*sin(goc)+0.5);
outtextxy(x,y,dso[i]);
}
gettime(&t);
gioht=t.ti_hour;
phutht=t.ti_min;
giayht=t.ti_sec;
phutgioht=phutht;
setwritemode(XOR_PUT);
ke_gio(gioht,phutgioht);
ke_phut(phutht);
ke_giay(giayht);
do
{
chay_kim_giay();
chay_kim_phut();
chay_kim_gio();
}while(!kbhit());
closegraph();
}
#include<graphics.h>
#include<conio.h>
#include<math.h>
#include<dos.h>
int x0,y0,rgio,rphut,rgiay,mgio,mphut,mgiay;
unsigned phutgioht,gioht,phutht,giayht;
void ke(int ddo, unsigned dai, unsigned day, unsigned mau)
{
unsigned x,y;
float goc;
while(ddo>=360)
ddo=ddo-360;
goc=(M_PI/180)*ddo;
x=x0+(int)(dai*cos(goc)+0.5);
y=y0-(int)(dai*sin(goc)+0.5);
setcolor(mau);
setlinestyle(0,0,day);
line(x0,y0,x,y);
}
void ke_giay(unsigned giay)
{
int ddo;
ddo=(90-6*giay);
ke(ddo,rgiay,1,mgiay);
}
void ke_phut(unsigned phut)
{
int ddo;
ddo=(90-6*phut);
ke(ddo,rphut,3,mphut);
}
void ke_gio(unsigned gio, unsigned phut)
{
int ddo;
ddo=360+90-30*(gio%12)-(phut+1)/2;
ke(ddo,rgio,3,mgio);
}
void chay_kim_giay(void)
{
unsigned giay;
struct time t;
gettime(&t);
giay=t.ti_sec;
if(giay!=giayht)
{
ke_giay(giayht);
giayht=giay;
ke_giay(giayht);
}
}
void chay_kim_phut(void)
{
unsigned phut;
struct time t;
gettime(&t);
phut=t.ti_min;
if(phut!=phutht)
{
ke_phut(phutht);
phutht=phut;
ke_phut(phutht);
}
}
void chay_kim_gio(void)
{
unsigned h,gio,phut,sophut,sophutht;
struct time t;
gettime(&t);
gio=t.ti_hour;
phut=t.ti_min;
sophut=gio*60+phut;
sophutht=gioht*60+phutgioht;
if(sophut<sophutht)
sophut=sophut+12*60;
h=sophut-sophutht;
if(h>=12)
{
ke_gio(gioht,phutgioht);
phutgioht=phut;
gioht=gio;
ke_gio(gioht,phutgioht);
}
}
void main()
{
struct time t;
char *dso[]={"","12","1","2","3","4","5","6","7","8","9","10","11"};
int i, mh=0, mode, r,x,y;
float goc;
initgraph(&mh,&mode,"E:\\BC\\BGI");
x0=(getmaxx()/2)-1;
y0=(getmaxy()/2)-1;
r=y0-2;
rgiay=r-10;
rphut=r-50;
rgio=r-90;
mgiay=BROWN;
mphut=RED;
mgio=YELLOW;
setcolor(BLUE);
setlinestyle(0,0,3);
circle(x0,y0,r);
setfillstyle(1,YELLOW);
floodfill(0,0,BLUE);
setfillstyle(1,WHITE);
floodfill(x0,y0,BLUE);
setlinestyle(0,0,1);
circle(x0,y0,10);
setfillstyle(1,GREEN);
floodfill(x0,y0,BLUE);
settextjustify(1,1);
setcolor(MAGENTA);
outtextxy(x0,y0+120,"TAH-JR");
settextstyle(3,0,3);
settextjustify(1,1);
setcolor(BLUE);
for(i=1;i<=12;i++)
{
goc=(2*M_PI+M_PI/2)-(i-1)*(M_PI/6);
x=x0+(int)(rphut*cos(goc)+0.5);
y=y0-(int)(rphut*sin(goc)+0.5);
outtextxy(x,y,dso[i]);
}
gettime(&t);
gioht=t.ti_hour;
phutht=t.ti_min;
giayht=t.ti_sec;
phutgioht=phutht;
setwritemode(XOR_PUT);
ke_gio(gioht,phutgioht);
ke_phut(phutht);
ke_giay(giayht);
do
{
chay_kim_giay();
chay_kim_phut();
chay_kim_gio();
}while(!kbhit());
closegraph();
}
Thứ Ba, 29 tháng 12, 2015
Chương trình tổng hợp các bài toán cơ bản về cây tìm kiếm nhị phân
#include<stdio.h>
#include<conio.h>
typedef struct tree
{
int info;
tree *l;
tree *r;
};
tree *getnode(int x)
{
tree *p=new tree;
if(!p) return NULL;
p->info= x;
p->l=NULL;
p->r=NULL;
return p;
}
void addx(tree *&t, int x)
{
if(!t)
{
t=getnode(x);
return;
}
if(t->info ==x) return;
if(t->info>x)
addx(t->l,x);
else
addx(t->r,x);
}
void list(tree *&t)
{
int n,x;
do
{
printf("\nNhap n: ");
scanf("%d",&n);
if(n<0) printf("\nNhap sai Nhap lai");
}while(n<0);
for(int i=0; i<n; i++)
{
printf("\nNhap x: ");
scanf("%d",&x);
addx(t,x);
}
}
void NLR(tree *t)
{
if(!t) return;
printf("%5d",t->info);
NLR(t->l);
NLR(t->r);
}
void LNR(tree *t)
{
if(!t) return;
LNR(t->l);
printf("%5d",t->info);
LNR(t->r);
}
void LRN(tree *t)
{
if(!t) return;
LRN(t->l);
LRN(t->r);
printf("%5d",t->info);
}
tree *timx(tree *t, int x)
{
if(!t) return NULL;
if(t->info==x) return t;
if(t->info >x)
return(timx(t->l,x));
return(timx(t->r,x));
}
tree *timx2(tree *t, int x)
{
tree *p=t;
if(!t) return NULL;
while(p && p->info !=x)
{
if(p->info >x)
p=p->l;
else p=p->r;
}
return p;
}
void calltimx(tree *t)
{
int x;
printf("\nNhap x can tim: ");
scanf("%d",&x);
if(!t)
printf("\nCay rong");
else
{
tree *p=timx(t,x);
if(!p)
printf("\nKhong tim thay");
else printf("\nTim thay");
}
}
int ktsnt(int n)
{
if(n<2) return 0;
if(n==2) return 1;
for(int i =2; i*i<=n; i++)
if(n%i == 0) return 0;
return 1;
}
void ktam(tree *t)
{
if(!t) return;
if(t->info<0)
printf("%5d",t->info);
ktam(t->l);
ktam(t->r);
}
void ktduong(tree *t)
{
if(!t) return;
if(t->info>0)
printf("%5d",t->info);
ktduong(t->l);
ktduong(t->r);
}
void ktchan(tree *t)
{
if(!t) return;
if(t->info%2==0)
printf("%5d",t->info);
ktchan(t->l);
ktchan(t->r);
}
void ktle(tree *t)
{
if(!t) return;
if(t->info%2!=0)
printf("%5d",t->info);
ktle(t->l);
ktle(t->r);
}
void xuatsnt(tree *t)
{
if(!t) return;
if(ktsnt(t->info))
printf("%5d",t->info);
xuatsnt(t->l);
xuatsnt(t->r);
}
int tong(tree *t)
{
if(!t) return 0;
return t->info + tong(t->l) +tong(t->r);
}
int tongam(tree *t)
{
if(!t) return 0;
if(t->info <0)
return t->info + tongam(t->l) + tongam(t->r);
return tongam(t->l) + tongam(t->r);
}
int tongduong(tree *t)
{
if(!t) return 0;
if(t->info >0)
return t->info + tongduong(t->l) + tongduong(t->r);
return tongduong(t->l) + tongduong(t->r);
}
int tongchan(tree *t)
{
if(!t) return 0;
if(t->info %2 == 0)
return t->info + tongchan(t->l) + tongchan(t->r);
return tongchan(t->l) + tongchan(t->r);
}
int tongle(tree *t)
{
if(!t) return 0;
if(t->info %2 != 0)
return t->info + tongle(t->l) + tongle(t->r);
return tongle(t->l) + tongle(t->r);
}
int tongsnt(tree *t)
{
if(!t) return 0;
if(ktsnt(t->info))
return t->info + tongsnt(t->l) + tongsnt(t->r);
return tongsnt(t->l) + tongsnt(t->r);
}
int demnode(tree *t)
{
if(!t) return 0;
return 1+ demnode(t->l)+demnode(t->r);
}
int demnodela(tree *t)
{
if(!t) return 0;
if(t->l == NULL && t->r == NULL)
return 1+demnodela(t->l) + demnodela(t->r);
return demnodela(t->l) + demnodela(t->r);
}
int demnodeam(tree *t)
{
if(!t) return 0;
if(t->info <0)
return 1+ demnodeam(t->l)+ demnodeam(t->r);
return demnodeam(t->l)+ demnodeam(t->r);
}
int demnodeduong(tree *t)
{
if(!t) return 0;
if(t->info >0)
return 1+ demnodeduong(t->l)+ demnodeduong(t->r);
return demnodeduong(t->l)+ demnodeduong(t->r);
}
int demnodechan(tree *t)
{
if(!t) return 0;
if(t->info %2 == 0)
return 1 + demnodechan(t->l) + demnodechan(t->r);
return demnodechan(t->l) + demnodechan(t->r);
}
int demnodele(tree *t)
{
if(!t) return 0;
if(t->info %2 != 0)
return 1 + demnodele(t->l) + demnodele(t->r);
return demnodele(t->l) + demnodele(t->r);
}
int demnodesnt(tree *t)
{
if(!t) return 0;
if(ktsnt(t->info))
return 1 + demnodesnt(t->l) + demnodesnt(t->r);
return demnodesnt(t->l) + demnodesnt(t->r);
}
int max(tree *t)
{
tree *p=t;
while(p->r)
p=p->r;
return p->info;
}
int min(tree *t)
{
tree *p=t;
while(p->l)
p=p->l;
return p->info;
}
tree *nodemax(tree *t)
{
tree *p=t;
while(p->r)
p=p->r;
return p;
}
tree *nodemin(tree *t)
{
tree *p=t;
while(p->l)
p=p->l;
return p;
}
int demnodelonx(tree *t, int x)
{
if(!t) return 0;
if(t->info >x)
return 1+demnodelonx(t->l,x) + demnodelonx(t->r,x);
return demnodelonx(t->l,x) + demnodelonx(t->r,x);
}
int demnodenhox(tree *t, int x)
{
if(!t) return 0;
if(t->info <x)
return 1+demnodenhox(t->l,x) + demnodenhox(t->r,x);
return demnodenhox(t->l,x) + demnodenhox(t->r,x);
}
int Max(int a, int b)
{
return a>b?a:b;
}
int height(tree *t)
{
if(t)
return 1+ Max(height(t->l), height(t->r));
return 0;
}
int xuatxy(tree *t, int x, int y)
{
if(!t) return 0;
if(t->info>=x && t->info <=y)
return 1+xuatxy(t->l,x,y)+xuatxy(t->r,x,y);
return xuatxy(t->l,x,y)+xuatxy(t->r,x,y);
}
void xuatxy1(tree *t)
{
int x,y;
printf("\nNhap x: ");
scanf("%d",&x);
printf("\nNhap y: ");
scanf("%d",&y);
printf("\nSo nut tu x den y trong cay la: %d",xuatxy(t,x,y));
}
void deltree(tree *&t)
{
if(!t) return;
deltree(t->l);
deltree(t->r);
delete t;
}
void main(void)
{
tree *t =NULL;
list(t);
printf("\nDuyet NLR: ");
NLR(t);
printf("\nDuyet LNR: ");
LNR(t);
printf("\nDuyet LRN: ");
LRN(t);
calltimx(t);
printf("\nCac so duong: ");
ktduong(t);
printf("\nCac so am: ");
ktam(t);
printf("\nCac so chan: ");
ktchan(t);
printf("\nCac so le: ");
ktle(t);
printf("\nCac so nguyen to: ");
xuatsnt(t);
printf("\nTong cac so duong trong cay: %d",tongduong(t));
printf("\nTong cac so le trong cay: %d",tongle(t));
printf("\nTong cac so chan trong cay: %d",tongchan(t));
printf("\nTong cac so am trong cay: %d",tongam(t));
printf("\nTong cac so nt trong cay: %d",tongsnt(t));
printf("\nTong so node tren cay: %d",demnode(t));
printf("\nTong so node la tren cay: %d",demnodela(t));
printf("\nTong cac so node duong trong cay: %d",demnodeduong(t));
printf("\nTong cac so node le trong cay: %d",demnodele(t));
printf("\nTong cac so node chan trong cay: %d",demnodechan(t));
printf("\nTong cac so node am trong cay:%d",demnodeam(t));
printf("\nTong cac so node nt trong cay: %d",demnodesnt(t));
printf("\nMax: %d",max(t));
printf("\nMin: %d",min(t));
int x;
printf("\nNhap x can tim: ");
scanf("%d",&x);
printf("\nTong cac node lon hon x: %d",demnodelonx(t,x));
printf("\nTong cac node nho hon x: %d",demnodenhox(t,x));
printf("\nChieu cao cua cay: %d",height(t));
xuatxy(t);
deltree(t);
if(t)
printf("\nCay da xoa !");
xuatxy1(t);
getch();
}
#include<conio.h>
typedef struct tree
{
int info;
tree *l;
tree *r;
};
tree *getnode(int x)
{
tree *p=new tree;
if(!p) return NULL;
p->info= x;
p->l=NULL;
p->r=NULL;
return p;
}
void addx(tree *&t, int x)
{
if(!t)
{
t=getnode(x);
return;
}
if(t->info ==x) return;
if(t->info>x)
addx(t->l,x);
else
addx(t->r,x);
}
void list(tree *&t)
{
int n,x;
do
{
printf("\nNhap n: ");
scanf("%d",&n);
if(n<0) printf("\nNhap sai Nhap lai");
}while(n<0);
for(int i=0; i<n; i++)
{
printf("\nNhap x: ");
scanf("%d",&x);
addx(t,x);
}
}
void NLR(tree *t)
{
if(!t) return;
printf("%5d",t->info);
NLR(t->l);
NLR(t->r);
}
void LNR(tree *t)
{
if(!t) return;
LNR(t->l);
printf("%5d",t->info);
LNR(t->r);
}
void LRN(tree *t)
{
if(!t) return;
LRN(t->l);
LRN(t->r);
printf("%5d",t->info);
}
tree *timx(tree *t, int x)
{
if(!t) return NULL;
if(t->info==x) return t;
if(t->info >x)
return(timx(t->l,x));
return(timx(t->r,x));
}
tree *timx2(tree *t, int x)
{
tree *p=t;
if(!t) return NULL;
while(p && p->info !=x)
{
if(p->info >x)
p=p->l;
else p=p->r;
}
return p;
}
void calltimx(tree *t)
{
int x;
printf("\nNhap x can tim: ");
scanf("%d",&x);
if(!t)
printf("\nCay rong");
else
{
tree *p=timx(t,x);
if(!p)
printf("\nKhong tim thay");
else printf("\nTim thay");
}
}
int ktsnt(int n)
{
if(n<2) return 0;
if(n==2) return 1;
for(int i =2; i*i<=n; i++)
if(n%i == 0) return 0;
return 1;
}
void ktam(tree *t)
{
if(!t) return;
if(t->info<0)
printf("%5d",t->info);
ktam(t->l);
ktam(t->r);
}
void ktduong(tree *t)
{
if(!t) return;
if(t->info>0)
printf("%5d",t->info);
ktduong(t->l);
ktduong(t->r);
}
void ktchan(tree *t)
{
if(!t) return;
if(t->info%2==0)
printf("%5d",t->info);
ktchan(t->l);
ktchan(t->r);
}
void ktle(tree *t)
{
if(!t) return;
if(t->info%2!=0)
printf("%5d",t->info);
ktle(t->l);
ktle(t->r);
}
void xuatsnt(tree *t)
{
if(!t) return;
if(ktsnt(t->info))
printf("%5d",t->info);
xuatsnt(t->l);
xuatsnt(t->r);
}
int tong(tree *t)
{
if(!t) return 0;
return t->info + tong(t->l) +tong(t->r);
}
int tongam(tree *t)
{
if(!t) return 0;
if(t->info <0)
return t->info + tongam(t->l) + tongam(t->r);
return tongam(t->l) + tongam(t->r);
}
int tongduong(tree *t)
{
if(!t) return 0;
if(t->info >0)
return t->info + tongduong(t->l) + tongduong(t->r);
return tongduong(t->l) + tongduong(t->r);
}
int tongchan(tree *t)
{
if(!t) return 0;
if(t->info %2 == 0)
return t->info + tongchan(t->l) + tongchan(t->r);
return tongchan(t->l) + tongchan(t->r);
}
int tongle(tree *t)
{
if(!t) return 0;
if(t->info %2 != 0)
return t->info + tongle(t->l) + tongle(t->r);
return tongle(t->l) + tongle(t->r);
}
int tongsnt(tree *t)
{
if(!t) return 0;
if(ktsnt(t->info))
return t->info + tongsnt(t->l) + tongsnt(t->r);
return tongsnt(t->l) + tongsnt(t->r);
}
int demnode(tree *t)
{
if(!t) return 0;
return 1+ demnode(t->l)+demnode(t->r);
}
int demnodela(tree *t)
{
if(!t) return 0;
if(t->l == NULL && t->r == NULL)
return 1+demnodela(t->l) + demnodela(t->r);
return demnodela(t->l) + demnodela(t->r);
}
int demnodeam(tree *t)
{
if(!t) return 0;
if(t->info <0)
return 1+ demnodeam(t->l)+ demnodeam(t->r);
return demnodeam(t->l)+ demnodeam(t->r);
}
int demnodeduong(tree *t)
{
if(!t) return 0;
if(t->info >0)
return 1+ demnodeduong(t->l)+ demnodeduong(t->r);
return demnodeduong(t->l)+ demnodeduong(t->r);
}
int demnodechan(tree *t)
{
if(!t) return 0;
if(t->info %2 == 0)
return 1 + demnodechan(t->l) + demnodechan(t->r);
return demnodechan(t->l) + demnodechan(t->r);
}
int demnodele(tree *t)
{
if(!t) return 0;
if(t->info %2 != 0)
return 1 + demnodele(t->l) + demnodele(t->r);
return demnodele(t->l) + demnodele(t->r);
}
int demnodesnt(tree *t)
{
if(!t) return 0;
if(ktsnt(t->info))
return 1 + demnodesnt(t->l) + demnodesnt(t->r);
return demnodesnt(t->l) + demnodesnt(t->r);
}
int max(tree *t)
{
tree *p=t;
while(p->r)
p=p->r;
return p->info;
}
int min(tree *t)
{
tree *p=t;
while(p->l)
p=p->l;
return p->info;
}
tree *nodemax(tree *t)
{
tree *p=t;
while(p->r)
p=p->r;
return p;
}
tree *nodemin(tree *t)
{
tree *p=t;
while(p->l)
p=p->l;
return p;
}
int demnodelonx(tree *t, int x)
{
if(!t) return 0;
if(t->info >x)
return 1+demnodelonx(t->l,x) + demnodelonx(t->r,x);
return demnodelonx(t->l,x) + demnodelonx(t->r,x);
}
int demnodenhox(tree *t, int x)
{
if(!t) return 0;
if(t->info <x)
return 1+demnodenhox(t->l,x) + demnodenhox(t->r,x);
return demnodenhox(t->l,x) + demnodenhox(t->r,x);
}
int Max(int a, int b)
{
return a>b?a:b;
}
int height(tree *t)
{
if(t)
return 1+ Max(height(t->l), height(t->r));
return 0;
}
int xuatxy(tree *t, int x, int y)
{
if(!t) return 0;
if(t->info>=x && t->info <=y)
return 1+xuatxy(t->l,x,y)+xuatxy(t->r,x,y);
return xuatxy(t->l,x,y)+xuatxy(t->r,x,y);
}
void xuatxy1(tree *t)
{
int x,y;
printf("\nNhap x: ");
scanf("%d",&x);
printf("\nNhap y: ");
scanf("%d",&y);
printf("\nSo nut tu x den y trong cay la: %d",xuatxy(t,x,y));
}
void deltree(tree *&t)
{
if(!t) return;
deltree(t->l);
deltree(t->r);
delete t;
}
void main(void)
{
tree *t =NULL;
list(t);
printf("\nDuyet NLR: ");
NLR(t);
printf("\nDuyet LNR: ");
LNR(t);
printf("\nDuyet LRN: ");
LRN(t);
calltimx(t);
printf("\nCac so duong: ");
ktduong(t);
printf("\nCac so am: ");
ktam(t);
printf("\nCac so chan: ");
ktchan(t);
printf("\nCac so le: ");
ktle(t);
printf("\nCac so nguyen to: ");
xuatsnt(t);
printf("\nTong cac so duong trong cay: %d",tongduong(t));
printf("\nTong cac so le trong cay: %d",tongle(t));
printf("\nTong cac so chan trong cay: %d",tongchan(t));
printf("\nTong cac so am trong cay: %d",tongam(t));
printf("\nTong cac so nt trong cay: %d",tongsnt(t));
printf("\nTong so node tren cay: %d",demnode(t));
printf("\nTong so node la tren cay: %d",demnodela(t));
printf("\nTong cac so node duong trong cay: %d",demnodeduong(t));
printf("\nTong cac so node le trong cay: %d",demnodele(t));
printf("\nTong cac so node chan trong cay: %d",demnodechan(t));
printf("\nTong cac so node am trong cay:%d",demnodeam(t));
printf("\nTong cac so node nt trong cay: %d",demnodesnt(t));
printf("\nMax: %d",max(t));
printf("\nMin: %d",min(t));
int x;
printf("\nNhap x can tim: ");
scanf("%d",&x);
printf("\nTong cac node lon hon x: %d",demnodelonx(t,x));
printf("\nTong cac node nho hon x: %d",demnodenhox(t,x));
printf("\nChieu cao cua cay: %d",height(t));
xuatxy(t);
deltree(t);
if(t)
printf("\nCay da xoa !");
xuatxy1(t);
getch();
}
Đăng ký:
Bài đăng (Atom)