E D R , A S I H C RSS

성우용

제로페이지 설명회

소개

소개

소개

소개

06학번성우용

경록

이름
성우용
stack
~cpp
#include <iostream>
using namespace std;

#define stack_size 100
char array[stack_size];
int top=-1;

void push(char ar);
int pop();
void main()
{
	//int index;
	//char array[stack_size];
	int i;
	char arraytemp;
	char array2[stack_size];
	FILE *fp;
	fp = fopen("abc.txt","r");
	fscanf(fp,"%s",array2);

	for (i=0;i<strlen(array2);i++) {
		push(array2[i]);
	}
	for (i=0;i<strlen(array2);i++) {
		arraytemp=pop();
		printf("%c",arraytemp);
	}

	fclose(fp);
}
void push(char ar)
{
	top++;
	array[top] = ar;
}
int pop()
{
	char temp;
	temp=array[top];
	top--;
	return temp;
}

오목
~cpp
#include <iostream>
using namespace std;
#define SIZE 19
int matrix[SIZE][SIZE];
void initial();
void print();
int main()
{
	int i,j,x_point,y_point;
	
	initial();

	while(1)
	{
		cout<<"x좌표를 입력하세요.";
		cin>>i;
		cout<<"y좌표를 입력하세요.";
		cin>>j;
		system("cls");
		if(i > SIZE || j > SIZE)
		{
			cout<<"바둑판 범위를 초과하였습니다.\n";
		}
		else
		{
			x_point = i-1;
			y_point = j-1;
			if(matrix[x_point][y_point] == 1)
			{
				cout<<"이미 돌이 놓여 있습니다.\n";
			}
			else
			{
				matrix[x_point][y_point] = 1;
				int k = -4;
				while(matrix[x_point][y_point+k] == 1)
				{
					if(k==0)
					{
						cout<<"성공!\n";
						print();
						return 0;
					}
					k++;
				}
				while(matrix[x_point+k][y_point] == 1)
				{
					if(k==0)
					{
						cout<<"성공!\n";
						print();
						return 0;
					}
					k++;
				}
				while(matrix[x_point+k][y_point+k] == 1)
				{
					if(k==0)
					{
						cout<<"성공!\n";
						print();
						return 0;
					}
					k++;
				}
				while(matrix[x_point][y_point-k] == 1)
				{
					if(k==0)
					{
						cout<<"성공!\n";
						print();
						return 0;
					}
					k++;
				}
				while(matrix[x_point-k][y_point] == 1)
				{
					if(k==0)
					{
						cout<<"성공!\n";
						print();
						return 0;
					}
					k++;
				}
				while(matrix[x_point-k][y_point-k] == 1)
				{
					if(k==0)
					{
						cout<<"성공!\n";
						print();
						return 0;
					}
					k++;
				}
				if(matrix[x_point][y_point+k] == 0)
				{
					while(matrix[x_point][y_point+k+1] == 1)
					{
						if(k==1)
						{
							cout<<"성공!\n";
							print();
							return 0;
							
						}
					k++;
					}
				}
				if(matrix[x_point+k][y_point] == 0)
				{
					while(matrix[x_point+k+1][y_point] == 1)
					{
						if(k==1)
						{
							cout<<"성공!\n";
							print();
							return 0;
						}
					k++;
					}
				}
				if(matrix[x_point+k][y_point+k] == 0)
				{
					while(matrix[x_point+k+1][y_point+k+1] == 1)
					{
						if(k==1)
						{
							cout<<"성공!\n";
							print();
							return 0;
						}
					k++;
					}	
				}
				if(matrix[x_point-k][y_point] == 0)
				{
					while(matrix[x_point-k-1][y_point] == 1)
					{
						if(k==1)
						{
							cout<<"성공!\n";
							print();
							return 0;
						}
					k++;
					}
				}
				if(matrix[x_point][y_point-k] == 0)
				{
					while(matrix[x_point][y_point-k-1] == 1)
					{
						if(k==1)
						{
							cout<<"성공!\n";
							print();
							return 0;
						}
					k++;
					}
				}
				if(matrix[x_point-k][y_point-k] == 0)
				{
					while(matrix[x_point-k-1][y_point-k-1] == 1)
					{
						if(k==1)
						{
							cout<<"성공!\n";
							print();
							return 0;
						}
					k++;
					}
				}
				/*for(int k=1; k<2 ;k++)
				{
					if(matrix[x_point][y_point+k] ==1)
					{
						cout<<"게임이 끝났습니다.\n";
						for (i=0;i<5;i++)
						{
							for (j=0;j<5;j++)
							{
								cout<<matrix[i][j]<<"   ";
							}
							cout<<"\n";
						}
						return 0;	
					}
					if(matrix[x_point+k][y_point] ==1)
					{
						cout<<"게임이 끝났습니다.\n";
						for (i=0;i<5;i++)
						{
							for (j=0;j<5;j++)
							{
								cout<<matrix[i][j]<<"   ";
							}
							cout<<"\n";
						}
						return 0;
					}
					if(matrix[x_point+k][y_point+k] ==1)
					{
						cout<<"게임이 끝났습니다.\n";
						for (i=0;i<5;i++)
						{
							for (j=0;j<5;j++)
							{
								cout<<matrix[i][j]<<"   ";
							}
							cout<<"\n";
						}
						return 0;
					}
					if(matrix[x_point][y_point-k] ==1)
					{
						cout<<"게임이 끝났습니다.\n";
						for (i=0;i<5;i++)
						{
							for (j=0;j<5;j++)
							{
								cout<<matrix[i][j]<<"   ";
							}
							cout<<"\n";
						}
						return 0;
					}
					if(matrix[x_point-k][y_point] ==1)
					{
						cout<<"게임이 끝났습니다.\n";
						for (i=0;i<5;i++)
						{
							for (j=0;j<5;j++)
							{
								cout<<matrix[i][j]<<"   ";
							}
							cout<<"\n";
						}
						return 0;
					}
					if(matrix[x_point-k][y_point-k] ==1)
					{
						cout<<"게임이 끝났습니다.\n";
						for (i=0;i<5;i++)
						{
							for (j=0;j<5;j++)
							{
								cout<<matrix[i][j]<<"   ";
							}
							cout<<"\n";
						}
						return 0;
					}
				}*/
			}
		}
		for (i=0;i<SIZE;i++)
		{
			for (j=0;j<SIZE;j++)
			{
				cout<<matrix[i][j]<<"   ";
			}
			cout<<"\n";
		}
	}
	return 0;
}

void initial() 
{
	for (int i=0;i<SIZE;i++)
	{
		for (int j=0;j<SIZE;j++)
		{
			matrix[i][j] = 0;
			cout<<matrix[i][j]<<"   ";
		}
		cout<<"\n";
	}
}
void print()
{
	for (int i=0;i<SIZE;i++)
		{
			for (int 
				j=0;j<SIZE;j++)
			{
				cout<<matrix[i][j]<<"   ";
			}
			cout<<"\n";
		}
}
== 안녕..난 순대야.. ==
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:12
Processing time 0.0232 sec