top of page

소스 코드 제출

공개·회원 71명

2025-05-18

/*

#include <stdio.h>

int queue[100000], fronttt=-1, backkk=-1;



void enqueue( int b )

{

backkk++;

queue[backkk]=b;

}



void dequeue()

{

if(fronttt==backkk)

{

return ;

}

fronttt++;

}



void front()

{

if(fronttt==backkk)

{

printf("-1\n");

}

else

{

printf("%d\n", queue[fronttt+1]);

}

}



void back()

{

if(fronttt==backkk)

{

printf("-1\n");

}

else

{

printf("%d\n", queue[backkk]);

}

}



void size()

{

printf("%d\n", backkk-fronttt);

}



void empty()

{

if(fronttt==backkk)

{

printf("true\n");

}

else

{

printf("false\n");

}

}



int main()

{

int a, b;

char arr[100];

scanf("%d", &a);

for(int i=1;i<=a;i++)

{

scanf("%s",arr);



if(arr[0]=='p' && arr[1]=='u')

{

scanf("%d )",&b);

enqueue(b);

}

else if(arr[0]=='p' && arr[1]=='o')

{

dequeue();

}

else if(arr[0]=='f')

{

front();

}

else if(arr[0]=='b')

{

back();

}

else if(arr[0]=='s')

{

size();

}

else

{

empty();

}

}

return 0;

}

*/

#include <stdio.h>

int s[100000]={}, topp=-1;



int push( int b )

{

topp++;

s[topp]=b;

}



void pop()

{

if(topp!=-1)

{

topp--;

}


}



void top()

{

if(topp==-1)

{

printf("-1\n");

}

else

{

printf("%d\n", topp);

}

}



void size()

{

printf("%d\n", topp+1);

}



void empty()

{

if(topp==-1)

{

printf("true\n");

}

else

{

printf("false\n");

}

}



int main()

{

int a, b;

char arr[100];

scanf("%d", &a);

for(int i=1;i<=a;i++)

{

scanf("%s", arr);

if(arr[0]=='p' && arr[1]=='u')

{

scanf("%d )", &b);

push(b);

}

else if(arr[0]=='t')

{

top();

}

else if(arr[0]=='p' && arr[1]=='o')

{

pop();

}

else if(arr[0]=='s')

{

size();

}

else

{

empty();

}

}

return 0;

}

2회 조회
주소 : 경기도 용인시 광교중앙로 302 블루 스퀘어 602호
연락처 : 031) 216 - 1546 ,     031) 215 - 1546
사업자등록번호 : 465-92-00916
​학원 등록 제 4603호
bottom of page