Code viết chử cho Dev C++ 4.9.9.2
4 posters
k4info :: Khu vực học tập :: Học Tập :: Thư viện :: Niên luận
Trang 1 trong tổng số 1 trang
Code viết chử cho Dev C++ 4.9.9.2
Mới google có được share các bác. Hơi dài ai có code nào pro hơn share nha.
- Code:
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#define BLACK 0
#define LIGHTGRAY 8
#define BLUE 9
#define GREEN 10
#define RED 12
#define YELLOW 14
#define WHITE 15
void gotoxy(short x,short y)
{
HANDLE hConsoleOutput;
COORD Cursor_an_Pos = { x,y};
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput , Cursor_an_Pos);
}
void textcolor(WORD color)
{
HANDLE hConsoleOutput;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
GetConsoleScreenBufferInfo(hConsoleOutput, &screen_buffer_info);
WORD wAttributes = screen_buffer_info.wAttributes;
color &= 0x000f;
wAttributes &= 0xfff0;
wAttributes |= color;
SetConsoleTextAttribute(hConsoleOutput, wAttributes);
}
void textbackground(WORD color)
{
HANDLE hConsoleOutput;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
GetConsoleScreenBufferInfo(hConsoleOutput, &screen_buffer_info);
WORD wAttributes = screen_buffer_info.wAttributes;
color &= 0x000f;
color <<= 4;
wAttributes &= 0xff0f;
wAttributes |= color;
SetConsoleTextAttribute(hConsoleOutput, wAttributes);
}
void VietChu( int xgoc , int ygoc , int xdich , int ydich , char *xau="Cuong" , int tre=15 , int mau = 10, int cach=1)
{
int i,j=0;
textcolor(mau);
if (xgoc==xdich&&ygoc>ydich&&cach==1)
{
for (j=0 ; j<=strlen(xau) ; j++)
{
if (xau[j]!=32)
for (i=ygoc ; i>= ydich ; i--)
{
gotoxy(xgoc,i);putch(xau[j]);
gotoxy(xgoc,i+1);putch(' ');
Sleep(tre);
}
else {gotoxy(xgoc,ydich);putch(' ');}
xgoc++;
}
}
if (ydich==ygoc&&xgoc>xdich&&cach==1)
{
for (j=0 ; j<=strlen(xau) ; j++)
{
if (xau[j]!=32)
for (i=xgoc ; i>= xdich ; i--)
{
gotoxy(i,ygoc);printf("%c ",xau[j]);
Sleep(tre);
}
else {gotoxy(xgoc,ydich);putch(' ');}
xdich++;
}
}
}
void clrscr(int c=BLACK,int top=0,int down=25)
{
textbackground(c);
gotoxy(0,top);
for(int i=top;i<down;i++)
printf(" ");
gotoxy(0,top);
}
int main(){
SetConsoleTitle("Viet Chu - C Programming Language");
clrscr(WHITE);
VietChu(79,1,25,1,"TRUONG DAI HOC TAY DO",2,12);
VietChu(79,2,30,2,"Nien Luan 1",2,12);
VietChu(46,10,5,10,"SV: THAI MINH CUONG",3);
VietChu(79,10,45,10,"GVHD: VUONG HUYNH LONG",3);
gotoxy(0,20);
system("pause");
};
shippou777- Posts : 460
Thanked : 8
11/10/2011
Tài Sản
Thú nuôi:
Re: Code viết chử cho Dev C++ 4.9.9.2
- Code:
#include <windows.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("HelloWin") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow (szAppName, // window class name
TEXT ("The Hello Program"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
switch (message)
{
case WM_CREATE:
return 0 ;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
GetClientRect (hwnd, &rect) ;
DrawText (hdc, TEXT ("Hello !"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
NeverGiveUp- Posts : 83
Thanked : 3
12/09/2011
Tài Sản
Thú nuôi:
Re: Code viết chử cho Dev C++ 4.9.9.2
Vừa ngắn vừa dể hiểu.
- Code:
#include "stdio.h"
#include "conio.h"
#include "windows.h"
void viet(char *xau="Cuong",int tre=15)
{
int i;
for ( i=0 ; i<strlen(xau) ; ++i)
{ putch(xau[i]);Sleep(tre);}
}
int main(){
viet("-------------Hello text--------------",50);
getch();
}
shippou777- Posts : 460
Thanked : 8
11/10/2011
Tài Sản
Thú nuôi:
Re: Code viết chử cho Dev C++ 4.9.9.2
thanks mấy chú đã đóng góp nhak!! làm màu mè we ko bik có rớt ko nữa??
Kid- Posts : 19
Thanked : -2
19/09/2011
Tài Sản
Thú nuôi:
Re: Code viết chử cho Dev C++ 4.9.9.2
Tuỳ sở thích mỗi người thôi và tuỳ vào người chấm bài nữa! Còn theo mình thì chương trình không lỗi! chạy đúng kết qua và đặc biệt là có tính logic là ok!
Re: Code viết chử cho Dev C++ 4.9.9.2
Tuỳ vào ông thầy chấm bài của mình nữa, màu mè tào lao quá ổng cho ra đảo là tiu
shippou777- Posts : 460
Thanked : 8
11/10/2011
Tài Sản
Thú nuôi:
Similar topics
» HELP ME!!! mình cần code c++ cho niên luân, code nén và giải nén tập tin văn bản bằng phương pháp huffman, ai có giúp mình với!!!
» BÀI TẬP TIẾNG VIỆT
» bộ game việt hóa java
» Bộ gỏ tiếng việt Vietkey 2007
» Webgame nhập vai 3D đầu tiên tại Việt Nam
» BÀI TẬP TIẾNG VIỆT
» bộ game việt hóa java
» Bộ gỏ tiếng việt Vietkey 2007
» Webgame nhập vai 3D đầu tiên tại Việt Nam
k4info :: Khu vực học tập :: Học Tập :: Thư viện :: Niên luận
Trang 1 trong tổng số 1 trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết
|
|