E D R , A S I H C RSS

변준원

No older revisions available

No older revisions available



Describe 변준원 here.

profile

이름: 변준원

학번: 03



Thread


여름방학 죽음의 1주일을 기다립니다..ㅎ

현재 데블스 캠프 진행중;; 내머리의 한계를 본다
이미 한계에 다다랐따 오버;

  • 준회원이 되신것을 축하합니다. 앞으로 많은 활동 부탁드려요~ -상욱(whiteblue)

  • 모르는 것이 있으면 자유게시판이나 위키 어느 곳이든 질문을 하셔도 됩니다. -상욱(whiteblue)

구구단
~cpp                                       
(define (f x)
  (when (< x 10) (begin  (print 2) (print *)(print x) (print =)(print (* 2 x)) (newline) (f (+ x 1)))))                                            
(f 1)


(define (f y) 
  (when (< y 10) (begin 
                   (define (f x)   (when (< x 10) (begin  (print y) 
                                                          (print *)
                                                          (print x)
                                                          (print =)
                                                          (print (* 2 x)) 
                                                          (newline) 
                                                          (f (+ x 1))
                                                   )
                                    )
                    ))
                   (f (+ y 1))))                                           
(f 1)

랜덤워크
~cpp 
#include<iostream>
#include<ctime>
using namespace std;
int move();
int check();
int x,y;
int number=0;
int matrix[5][5];

int main()
{
	const int max=5;
	int matrix[max][max];
	for(int i=0;i<5;i++)
	{
		for(int j=0;j<5;j++)
			matrix[i][j]=0;
	}
	
	srand(time(0));      // 바퀴벌레 랜덤 놓기
	int a = rand() % 5;
	int b = rand() % 5;
	matrix[a][b]=1;
	int p = rand() %3 -1; // 랜덤 옮기기
	int q = rand() %3 -1;
	x = a + p;
	y = b + q;
	if((x<5 && x>=0) && (y<5 && y>=0) && x!=0 && y!=0)
		 matrix[x][y]=1;
	else
		move();	
	
	
	return x,y;
}


int move()
{
	srand(time(0)); 
	int p = rand() %3 -1;
	int q = rand() %3 -1;
	
	x = x + p;
	y = y + q;
	if((x<5 && x>=0) && (y<5 && y>=0) && x!=0 && y!=0)
		 matrix[x][y]=1;
		 number++;
		 check();
		 
	
	move();
	return 0;
}

int check()
{	
	for(int m=0;m<5;m++)
	{
		for(int n=0;n<5;n++)
		{
			if(matrix[m][n]==1)
				move();
		}
				
	}
	
	
	for(int ga=0;ga<5;ga++)
	{
		for(int se=0;se<5;se++)
			cout << matrix[ga][se];
		
				
	}
	return 0;

}


8queen
~cpp 
#include<iostream>
using namespace std;


int main()
{
	int queen[8][8];
	int i,j,k/*,l,*/,m,n;
	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
			queen[i][j]=0;		
	}

	/* for(i=0;i<2;i++)
	{  */
		for(k=2;k<4;k++)
			queen[k-2][k]=1;
			queen[k-1][k+2]=1;
		/*{
			for(k=2;k<4;k++)
				queen[k][k-2]=1;
				queen[k+2][k-1]=1;
				for(l=0;l<j;l++)
				{
					if(queen[j-2+l][j-l]==queen[k][k-2])
					cout << "break";
					else
					{
						for(m=0;m<8;m++)
						{
							for(n=0;n<8;n++)
								cout << queen[m][n] ;
								cout <<endl;
						}
					}*/
					
					
						for(m=0;m<8;m++)
						{
							for(n=0;n<8;n++)
								cout << queen[m][n] ;
								cout <<endl;
						}
					
					
					

//				}
							

	
	
	return 0;


		}



만년달력

~cpp 
#include<iostream>
using namespace std;

int main()
{
	int year,code2;
	int yearcharac;
	int	code=5;
	cin >> year;
	for(int i=1;i<=year;i++)
	{	
		code++;
		yearcharac=0;
		{
		if(i%4==0)
			code++;
			yearcharac=1;
			{
			if(i%100==0)
				code--;
				yearcharac=0;
				{
					if(i%400==0)
					code++;
					yearcharac=1;
					{
						if(i%4000==0)
							code--;
							yearcharac=0;
					}
				}
					
			}
		}
	}
	code2 = code % 7;
	cout << code2;
	
	int calendar[7][6];
	int day=1;
	int m=0,n,p,q;
	
	for(p=0;p<=5;p++)
	{
		for(q=0;q<=6;q++)
			calendar[p][q]=0;
	}
	
	int monthcode[12] = {1, 4, 4, 0, 2, 5, 0 ,3 ,6 ,1 ,4 ,6};
	int monthday[12] = {31,28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int ymonthcode[12] = {1, 4, 5, 1, 3, 6, 1 ,4 ,0 ,0 ,5 ,0};
	int ymonthday[12] = {31,29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int month;
	cin >> month;
	if(yearcharac==0)
	{
		for(n=(code2+monthcode[month-1])%7;n<7;n++)
				{
					if(day<=monthday[month-1])
						calendar[m][n]=day;
						day++;
				}
					
		day++;
		
		while(day<=monthday[month-1])
		{
		
			for(n=0%7;n<7;n++)
			{
				if(day<=monthday[month-1])
					calendar[m+1][n]=day;
					day++;
					m++;
			}
		}
			
		
	}
	
	else //if(yearcharac==1)
	{
		for(n=(code2+ymonthcode[month-1])%7;n<7;n++)
			{
				if(day<=ymonthday[month-1])
					calendar[m][n]=day;
					day++;
			}
					
		day++;
		
		while(day<=ymonthday[month-1])
		{
		
			for(n=0%7;n<7;n++)
			{
				if(day<=ymonthday[month-1])
					calendar[m+1][n]=day;
					day++;
					m++;
			}
		}
			
		
	}

	for(p=0;p<=5;p++)
	{
		for(q=0;q<=6;q++)
			cout << calendar[p][q] << "\t";
			cout << endl;
	}
		
	return 0;
}

창 띄우기
~cpp 
#ifndef WIN32_LEAN_AND_MEAN 
#define WIN32_LEAN_AND_MEAN 
#endif 
 
 
#ifndef WIN32_LEAN_AND_MEAN 
#define WIN32_LEAN_AND_MEAN 
#endif 
 
#include <windows.h>
#include <iostream>
using namespace std;
 
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 
 
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) 
{ 
        MSG      msg; 
        HWND     hWnd; 
        WNDCLASS         wc; 
         
        wc.lpszClassName = "DXTEST"; 
        wc.lpfnWndProc   = WndProc; 
        wc.style         = CS_VREDRAW | CS_HREDRAW; 
        wc.hInstance     = hInstance; 
        wc.hIcon         = LoadIcon( NULL, IDI_APPLICATION ); 
        wc.hCursor       = LoadCursor( NULL, IDC_ARROW ); 
        wc.hbrBackground = (HBRUSH) (GetStockObject(WHITE_BRUSH)); 
        wc.lpszMenuName  = NULL; 
        wc.cbClsExtra    = 0; 
        wc.cbWndExtra    = 0; 
     
        RegisterClass( &wc ); 
        hWnd = CreateWindowEx( 0, "DXTEST", "DXTEST", 
                        WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 
                        CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL ); 
        ShowWindow(hWnd, nCmdShow); 
        UpdateWindow(hWnd); 
 
        while(true) 
        { 
                if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) 
                { 
                        if( 0 == GetMessage(&msg, NULL, 0, 0 ) ) 
                        {
							return (int)msg.wParam; 
                        } 
                        TranslateMessage( &msg );  
                        DispatchMessage( &msg ); 
                } 
                else 
                { 
                        
                } 
        } 
        cout << "Hello World";
		return (int)msg.wParam; 
} 
 
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) 
{ 
        PAINTSTRUCT PS;
		HDC hdc;
		switch(msg) 
        { 
        case WM_DESTROY: 
                PostQuitMessage(0); 
                break; 
		case WM_LBUTTONDOWN:
			MessageBox(NULL, "왜날&#49165; " , "오이좀줘", MB_OK);
			break;
		case WM_KEYDOWN:
			MessageBox(NULL, "asdf", "asdf" , MB_OK);
			break;
		case WM_PAINT:
			hdc=BeginPaint(hWnd, &PS) ;
			Rectangle(hdc,100,100,200,200);
			EndPaint(hWnd, &PS);
			
		} 
        return DefWindowProc(hWnd, msg, wParam, lParam); 
	
} 



엉터리 랜덤워크
~cpp 
#include<iostream> 
#include<ctime> 
using namespace std; 
 
int main() 
{ 
        const int max=5; 
        int matrix[max][max]; 
        for(int i=0;i<5;i++) 
        { 
                for(int j=0;j<5;j++) 
                        matrix[i][j]=0; 
        } 
         
        srand(time(0));      // 바퀴벌레 랜덤 놓기 
        int x = rand() % 5; 
        int y = rand() % 5; 
        int p, q;
		matrix[x][y]=1; 
        
		int count=0, number=0;//엔딩수, 이동수 지정
		while(count<24)
		{
			int moving = rand() % 8;
			if (moving==0) //북
				p=0,q=-1;
			else if(moving == 1) //북동
				p=1,q=-1;
			else if(moving == 2)//동
				p=1,q=0;
			else if(moving == 3) //남동
				p=1,q=1;
			else if(moving == 4) //남
				p=0,q=-1;
			else if(moving == 5) //남서
				p=-1,q=1;
			else if(moving == 6) //서
				p=-1,q=0;
			else if(moving == 7) //북서
				p=-1,q=-1;
			x = x + p; 
			y = y + q; 
			if((x<=4 && x>=0) && (y<=4 && y>=0)) // 틀 안쪽인지를 검사
			{
				if(matrix[x][y]==0) //자리 확인
				{	
					matrix[x][y]=matrix[x][y]+1;
					count++;
					number++;
				}

				else
				{
					matrix[x][y]=matrix[x][y]+1;
					number++;
				}
			}
			else // 틀 밖일때 바퀴 되 돌리기
			{
				x=x-p;
				y=y-q;
			}
		};	
		for(int ga=0;ga<5;ga++) 
        { 
			for(int se=0;se<5;se++) 
				cout << matrix[ga][se] << "\t"; 
			cout<<endl;
        } 
		cout<<endl;

		cout << "바퀴벌레의 이동횟수는 " << number << "입니다." << endl;                
		
         
         
	return 0;        

} 





Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:35
Processing time 0.0251 sec