k4info
Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.

Code viết chử cho Dev C++ 4.9.9.2

4 posters

Go down

funy Code viết chử cho Dev C++ 4.9.9.2

Bài gửi by shippou777 Sat Nov 19, 2011 7:04 pm

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");
};   
.


Code viết chử cho Dev C++ 4.9.9.2 Anhso-19746_h1
Code viết chử cho Dev C++ 4.9.9.2 Anhso-19749_h2
avatar
shippou777

Posts : 460
Thanked : 8
Gia Nhập 11/10/2011

Tài Sản
Thú nuôi:

Về Đầu Trang Go down

funy Re: Code viết chử cho Dev C++ 4.9.9.2

Bài gửi by NeverGiveUp Sun Nov 20, 2011 8:28 pm

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
NeverGiveUp

Posts : 83
Thanked : 3
Gia Nhập 12/09/2011

Tài Sản
Thú nuôi:

Về Đầu Trang Go down

funy Re: Code viết chử cho Dev C++ 4.9.9.2

Bài gửi by shippou777 Sun Nov 20, 2011 8:42 pm

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();
}

avatar
shippou777

Posts : 460
Thanked : 8
Gia Nhập 11/10/2011

Tài Sản
Thú nuôi:

Về Đầu Trang Go down

funy Re: Code viết chử cho Dev C++ 4.9.9.2

Bài gửi by Kid Thu Nov 24, 2011 12:11 am

thanks mấy chú đã đóng góp nhak!! làm màu mè we ko bik có rớt ko nữa??
Kid
Kid

Posts : 19
Thanked : -2
Gia Nhập 19/09/2011

Tài Sản
Thú nuôi:

Về Đầu Trang Go down

funy Re: Code viết chử cho Dev C++ 4.9.9.2

Bài gửi by Admin Thu Nov 24, 2011 10:19 am

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!
Admin
Admin

Posts : 1013
Thanked : 47
Gia Nhập 25/08/2010

Tài Sản
Thú nuôi:

https://k4info.forumvi.com

Về Đầu Trang Go down

funy Re: Code viết chử cho Dev C++ 4.9.9.2

Bài gửi by shippou777 Thu Nov 24, 2011 10:28 am

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 Code viết chử cho Dev C++ 4.9.9.2 2300005787
avatar
shippou777

Posts : 460
Thanked : 8
Gia Nhập 11/10/2011

Tài Sản
Thú nuôi:

Về Đầu Trang Go down

funy Re: Code viết chử cho Dev C++ 4.9.9.2

Bài gửi by Sponsored content


Sponsored content


Về Đầu Trang Go down

Về Đầu Trang

- Similar topics

 
Permissions in this forum:
Bạn không có quyền trả lời bài viết