/*#include <stdio.h>
#include <conio.h>
#include <windows.h>
#define UP 72
#define DOWN 80
#define LEFT 75
#define RIGHT 77
int px=10 ;
int py=10 ;
int score=1;
int a=0; // 이동방향
void gotoxy(int x, int y)
{
COORD Pos = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Pos);
}
void map(int r1, int r2)
{
gotoxy(px,py);
printf ("*");
gotoxy(r1,r2);
printf ("@");
}
void init() //초기상태
{
for (int x=0; x<31; x++){
for (int y=0; y<31; y++){
gotoxy(x, y);
if (x==0||y==0||x==30||y==30){
printf (".");
}
}
}
gotoxy(45,2);
printf("점수 : %d", score);
}
int main()
{
char c;
int i=0, j=0;
int arrx[10000];
int arry[10000];
srand(time(NULL)); //랜덤 시드 설정 (최초 한 번만!)
int random = rand()%29+1;
int random2=rand()%29+1;
//system( "mode con lines=33 cols=55" );
for (;;){
if (_kbhit()) { //키보드 입력 확인 (true / false)
c = _getch();
if (c == -32) { // -32로 입력되면
c = _getch(); // 새로 입력값을 판별하여 상하좌우 출력
switch (c) {
case LEFT:
if (a==2&&score!=1){
break;
}
a=1;
break;
case RIGHT:
if (a==1&&score!=1){
break;
}
a=2;
break;
case UP:
if (a==4&&score!=1){
break;
}
a=3;
break;
case DOWN:
if (a==3&&score!=1){
break;
}
a=4;
break;
}
}
}
switch (a){
case 1:
px--;
break;
case 2:
px++;
break;
case 3:
py--;
break;
case 4:
py++;
break;
}
i++;
i%=10000;
j%=10000;
arrx[i]=px;
arry[i]=py;
gotoxy(arrx[j], arry[j]);
printf (" ");
j++;
if(px==0||px==31||py==0||py==31){
system ("cls");
printf ("\n점수 : %d\n", score);
return 0;
}
map(random, random2);
if (px==random&&py==random2){
gotoxy (random, random2);
printf ("*");
random=rand()%29+1;
random2=rand()%29+1;
gotoxy(random, random2);
printf ("@");
score++;
j--;
}
init();
Sleep(70);
}
}
*********게임 기능 정리 *********
1. 누른 방향키 방향대로 직진함
2. 벽에 닿으면 게임이 끝남
3. 아이템 @를 먹으면 몸이 1칸씩 늘어남+점수가 늘어남
**************************/
/*
#include<stdio.h>
#include<string.h>
char stack[100];
int top=-1;
void push(char data)
{
top++;
stack[top]=data;
}
char pop()
{
if(top==-1) return 0; //스택의 empty 체크!!
return stack[top--];
}
int main()
{
char n[100]={};
scanf("%s",n);
for (int i=0; n[i]!=NULL; i++){
push(n[i]);
}
while(top!=-1){
printf ("%c", pop());
}
return 0;
}
8
12345678 -> 12,345,678
6
123456 -> 123,456
#include<stdio.h>
#include<string.h>
char stack[300];
int top=-1;
void push(char data)
{
top++;
stack[top]=data;
}
char pop()
{
if (top==-1){
return 0;
}
return stack[top--];
}
int main()
{
char n[200]={};
int a,cnt=0;
scanf ("%d", &a);
scanf ("%s",n);
for (int i=a-1; i>=0; i--){
push(n[i]);
cnt++;
if (cnt%3==0&&cnt!=a){
push(',');
}
}
while(top!=-1){
printf ("%c", pop());
}
return 0;
}
#include<stdio.h>
#include<string.h>
char stack[100000];
int top=-1;
void push(int data)
{
top++;
stack[top]=data;
}
int pop()
{
if (top==-1){
return 0;
}
return stack[top--];
}
int main()
{
int k, sum=0, i, a;
scanf ("%d", &k);
for (i=0; i<k; i++){
scanf ("%d", &a);
if (a==0){
top--;
continue;
}
push(a);
}
while (top!=-1){
sum+=pop();
}
printf ("%d", sum);
return 0;
}
*/
#include<stdio.h>
#include<string.h>
char stack[50000];
int top=-1;
int main()
{
char a[50000];
int i;
scanf ("%s", a);
while (a[i]!=NULL){
i=0;
if ()
}
}
/*
(()())
(저장
)가 나왔을 때 가장 위에 있는 ( 지우기
stack에 남으면 bad 아니면 good
*/