Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

성우용: Difference between revisions

From ZeroWiki
imported>Unknown
No edit summary
 
(Repair batch-0006 pages from live compare)
 
Line 6: Line 6:
06학번성우용
06학번성우용


[[이경록]]
이경록


{| class="wikitable"
{| class="wikitable"
Line 24: Line 24:
   
   
  #define stack_size 100
  #define stack_size 100
  char array[stack_size];
  char array[stack_size];
  int top=-1;
  int top=-1;
   
   
Line 32: Line 32:
  {
  {
  //int index;
  //int index;
  //char array[stack_size];
  //char array[stack_size];
  int i;
  int i;
  char arraytemp;
  char arraytemp;
  char array2[stack_size];
  char array2[stack_size];
  FILE *fp;
  FILE *fp;
  fp = fopen("abc.txt","r");
  fp = fopen("abc.txt","r");
Line 41: Line 41:
   
   
  for (i=0;i<strlen(array2);i++) {
  for (i=0;i<strlen(array2);i++) {
  push(array2[i]);
  push(array2[i]);
  }
  }
  for (i=0;i<strlen(array2);i++) {
  for (i=0;i<strlen(array2);i++) {
Line 53: Line 53:
  {
  {
  top++;
  top++;
  array[top] = ar;
  array[top] = ar;
  }
  }
  int pop()
  int pop()
  {
  {
  char temp;
  char temp;
  temp=array[top];
  temp=array[top];
  top--;
  top--;
  return temp;
  return temp;
Line 66: Line 66:
  using namespace std;
  using namespace std;
  #define SIZE 19
  #define SIZE 19
  int matrix[SIZE][SIZE];
  int matrix[SIZE][SIZE];
  void initial();
  void initial();
  void print();
  void print();
Line 90: Line 90:
  x_point = i-1;
  x_point = i-1;
  y_point = j-1;
  y_point = j-1;
  if(matrix[x_point][y_point] == 1)
  if(matrix[x_point][y_point] == 1)
  {
  {
  cout<<"이미 돌이 놓여 있습니다.\n";
  cout<<"이미 돌이 놓여 있습니다.\n";
Line 96: Line 96:
  else
  else
  {
  {
  matrix[x_point][y_point] = 1;
  matrix[x_point][y_point] = 1;
  int k = -4;
  int k = -4;
  while(matrix[x_point][y_point+k] == 1)
  while(matrix[x_point][y_point+k] == 1)
  {
  {
  if(k==0)
  if(k==0)
Line 108: Line 108:
  k++;
  k++;
  }
  }
  while(matrix[x_point+k][y_point] == 1)
  while(matrix[x_point+k][y_point] == 1)
  {
  {
  if(k==0)
  if(k==0)
Line 118: Line 118:
  k++;
  k++;
  }
  }
  while(matrix[x_point+k][y_point+k] == 1)
  while(matrix[x_point+k][y_point+k] == 1)
  {
  {
  if(k==0)
  if(k==0)
Line 128: Line 128:
  k++;
  k++;
  }
  }
  while(matrix[x_point][y_point-k] == 1)
  while(matrix[x_point][y_point-k] == 1)
  {
  {
  if(k==0)
  if(k==0)
Line 138: Line 138:
  k++;
  k++;
  }
  }
  while(matrix[x_point-k][y_point] == 1)
  while(matrix[x_point-k][y_point] == 1)
  {
  {
  if(k==0)
  if(k==0)
Line 148: Line 148:
  k++;
  k++;
  }
  }
  while(matrix[x_point-k][y_point-k] == 1)
  while(matrix[x_point-k][y_point-k] == 1)
  {
  {
  if(k==0)
  if(k==0)
Line 158: Line 158:
  k++;
  k++;
  }
  }
  if(matrix[x_point][y_point+k] == 0)
  if(matrix[x_point][y_point+k] == 0)
  {
  {
  while(matrix[x_point][y_point+k+1] == 1)
  while(matrix[x_point][y_point+k+1] == 1)
  {
  {
  if(k==1)
  if(k==1)
Line 172: Line 172:
  }
  }
  }
  }
  if(matrix[x_point+k][y_point] == 0)
  if(matrix[x_point+k][y_point] == 0)
  {
  {
  while(matrix[x_point+k+1][y_point] == 1)
  while(matrix[x_point+k+1][y_point] == 1)
  {
  {
  if(k==1)
  if(k==1)
Line 185: Line 185:
  }
  }
  }
  }
  if(matrix[x_point+k][y_point+k] == 0)
  if(matrix[x_point+k][y_point+k] == 0)
  {
  {
  while(matrix[x_point+k+1][y_point+k+1] == 1)
  while(matrix[x_point+k+1][y_point+k+1] == 1)
  {
  {
  if(k==1)
  if(k==1)
Line 198: Line 198:
  }
  }
  }
  }
  if(matrix[x_point-k][y_point] == 0)
  if(matrix[x_point-k][y_point] == 0)
  {
  {
  while(matrix[x_point-k-1][y_point] == 1)
  while(matrix[x_point-k-1][y_point] == 1)
  {
  {
  if(k==1)
  if(k==1)
Line 211: Line 211:
  }
  }
  }
  }
  if(matrix[x_point][y_point-k] == 0)
  if(matrix[x_point][y_point-k] == 0)
  {
  {
  while(matrix[x_point][y_point-k-1] == 1)
  while(matrix[x_point][y_point-k-1] == 1)
  {
  {
  if(k==1)
  if(k==1)
Line 224: Line 224:
  }
  }
  }
  }
  if(matrix[x_point-k][y_point-k] == 0)
  if(matrix[x_point-k][y_point-k] == 0)
  {
  {
  while(matrix[x_point-k-1][y_point-k-1] == 1)
  while(matrix[x_point-k-1][y_point-k-1] == 1)
  {
  {
  if(k==1)
  if(k==1)
Line 239: Line 239:
  /*for(int k=1; k<2 ;k++)
  /*for(int k=1; k<2 ;k++)
  {
  {
  if(matrix[x_point][y_point+k] ==1)
  if(matrix[x_point][y_point+k] ==1)
  {
  {
  cout<<"게임이 끝났습니다.\n";
  cout<<"게임이 끝났습니다.\n";
Line 246: Line 246:
  for (j=0;j<5;j++)
  for (j=0;j<5;j++)
  {
  {
  cout<<matrix[i][j]<<"  ";
  cout<<matrix[i][j]<<"  ";
  }
  }
  cout<<"\n";
  cout<<"\n";
Line 252: Line 252:
  return 0;
  return 0;
  }
  }
  if(matrix[x_point+k][y_point] ==1)
  if(matrix[x_point+k][y_point] ==1)
  {
  {
  cout<<"게임이 끝났습니다.\n";
  cout<<"게임이 끝났습니다.\n";
Line 259: Line 259:
  for (j=0;j<5;j++)
  for (j=0;j<5;j++)
  {
  {
  cout<<matrix[i][j]<<"  ";
  cout<<matrix[i][j]<<"  ";
  }
  }
  cout<<"\n";
  cout<<"\n";
Line 265: Line 265:
  return 0;
  return 0;
  }
  }
  if(matrix[x_point+k][y_point+k] ==1)
  if(matrix[x_point+k][y_point+k] ==1)
  {
  {
  cout<<"게임이 끝났습니다.\n";
  cout<<"게임이 끝났습니다.\n";
Line 272: Line 272:
  for (j=0;j<5;j++)
  for (j=0;j<5;j++)
  {
  {
  cout<<matrix[i][j]<<"  ";
  cout<<matrix[i][j]<<"  ";
  }
  }
  cout<<"\n";
  cout<<"\n";
Line 278: Line 278:
  return 0;
  return 0;
  }
  }
  if(matrix[x_point][y_point-k] ==1)
  if(matrix[x_point][y_point-k] ==1)
  {
  {
  cout<<"게임이 끝났습니다.\n";
  cout<<"게임이 끝났습니다.\n";
Line 285: Line 285:
  for (j=0;j<5;j++)
  for (j=0;j<5;j++)
  {
  {
  cout<<matrix[i][j]<<"  ";
  cout<<matrix[i][j]<<"  ";
  }
  }
  cout<<"\n";
  cout<<"\n";
Line 291: Line 291:
  return 0;
  return 0;
  }
  }
  if(matrix[x_point-k][y_point] ==1)
  if(matrix[x_point-k][y_point] ==1)
  {
  {
  cout<<"게임이 끝났습니다.\n";
  cout<<"게임이 끝났습니다.\n";
Line 298: Line 298:
  for (j=0;j<5;j++)
  for (j=0;j<5;j++)
  {
  {
  cout<<matrix[i][j]<<"  ";
  cout<<matrix[i][j]<<"  ";
  }
  }
  cout<<"\n";
  cout<<"\n";
Line 304: Line 304:
  return 0;
  return 0;
  }
  }
  if(matrix[x_point-k][y_point-k] ==1)
  if(matrix[x_point-k][y_point-k] ==1)
  {
  {
  cout<<"게임이 끝났습니다.\n";
  cout<<"게임이 끝났습니다.\n";
Line 311: Line 311:
  for (j=0;j<5;j++)
  for (j=0;j<5;j++)
  {
  {
  cout<<matrix[i][j]<<"  ";
  cout<<matrix[i][j]<<"  ";
  }
  }
  cout<<"\n";
  cout<<"\n";
Line 324: Line 324:
  for (j=0;j<SIZE;j++)
  for (j=0;j<SIZE;j++)
  {
  {
  cout<<matrix[i][j]<<"  ";
  cout<<matrix[i][j]<<"  ";
  }
  }
  cout<<"\n";
  cout<<"\n";
Line 338: Line 338:
  for (int j=0;j<SIZE;j++)
  for (int j=0;j<SIZE;j++)
  {
  {
  matrix[i][j] = 0;
  matrix[i][j] = 0;
  cout<<matrix[i][j]<<"  ";
  cout<<matrix[i][j]<<"  ";
  }
  }
  cout<<"\n";
  cout<<"\n";
Line 351: Line 351:
  j=0;j<SIZE;j++)
  j=0;j<SIZE;j++)
  {
  {
  cout<<matrix[i][j]<<"  ";
  cout<<matrix[i][j]<<"  ";
  }
  }
  cout<<"\n";
  cout<<"\n";
Line 357: Line 357:
  }
  }
  == 안녕..난 순대야.. ==
  == 안녕..난 순대야.. ==

Latest revision as of 01:08, 27 March 2026

제로페이지 설명회

소개

소개

소개

소개

06학번성우용

이경록

이름
성우용

stack

#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;
}

오목

#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";
		}
}
== 안녕..난 순대야.. ==