//stack sample
/*
#include <stdio.h>
#define SIZE 100
int stack[SIZE];
int top=0; //마지막 데이터의 위치
void push(int data) //stack에 데이터 넣기
{
stack[++top]=data;
}
int pop() //stack에서 데이터 나와라
{
if(top==0) return -1;
return stack[top--];
}
void view()
{
int i;
printf("stack >> ");
for(i=1;i<=top;i++)
{
printf("%d ",stack[i]);
}
printf(" top : %d\n",top);
}
int main()
{
int a, b, c,d;
while(1)
{
printf("1.push 2.pop >> ");
scanf("%d",&a);
if(a==1)
{
printf("input data >>");
scanf("%d",&b);
push(b);
view();
}
else
{
c=pop();
if(c==-1)
{
printf("stack is empty!\n");
}
else
{
printf("pop data >> %d\n",c);
view();
}
}
}
push(3);
push(5);
push(1);
push(2);
push(7);
view();
printf("%d\n",pop());
view();
printf("%d\n",pop());
view();
printf("%d\n",pop());
view();
printf("%d\n",pop());
view();
printf("%d\n",pop());
view();
printf("%d\n",pop());
view();
printf("%d\n",pop());
view();
printf("%d\n",pop());
view();
return 0;
}
#include <stdio.h>
#define SIZE 100
char stack[SIZE];
int top=0;
void push(char data) //stack에 데이터 넣기
{
stack[++top]=data;
}
char pop()
{
if(top==0) return -1;
return stack[top--];
}
int main()
{
char str[50]={0};
scanf("%s",str);
for(int i=0; str[i]!=0; i++)
{
//stack[++top]=str[i];
push(str[i]);
}
while(top!=0) //stack의 데이터를 모두 pop해라
{
printf("%c",pop());
}
}
#include <stdio.h>
#define SIZE 100000
int stack[SIZE];
int top=0;
void push(int data)
{
stack[++top]=data;
}
int pop()
{
if(top==0)
return -1;
return stack[top--];
}
int main()
{
int n,m,k=0;
scanf("%d",&n);
for(int i=0; i<n; i++)
{
scanf("%d",&m);
if(m==0)
{
pop();
}
else
{
push(m);
}
}
while(top!=0)
{
k+=pop();
}
printf("%d",k);
return 0;
}
*/
#include <stdio.h>
#define SIZE 200
int stack[SIZE];
int top=0;
void push(int data)
{
stack[++top]=data;
}
int pop()
{
if(top==0)
return -1;
return stack[top--];
}
int main()
{
int n,memo[201]={0},k,i;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%1d",&memo[i]);
}
for(i=n;i>=1;i--)
{
push(memo[i]);
}
while(top!=0)
{
printf("%d",pop());
if(top%3==0&&top!=0)
{
printf(",");
}
}
}