KakaoTalk_20190606_001802318.png
  • 246x0w
Welcome
Curriculum
Install&Go
Board
실제 작동 상태를 확인하려면 라이브 사이트로 이동하세요.
  • 카테고리
  • 전체 게시물
  • 내 게시물
wimpy15
2020년 4월 14일

stack

게시판: 소스 코드 제출

/*


#include <stdio.h>

#define SIZE 5


int st[SIZE]={};

int top;


void Init(){

top=-1;

}


void push(int n){


if(top == SIZE-1)

{

printf("꽉찼다 그만 넣어라\n");

return;

}

top++;

st[top]=n;


return ;

}


void pop(){


if(top==-1)

{

printf("비어서 못 뺀다\n");

return ;

}

printf("%d\n",st[top]);

st[top]=0;

top--;


}


void view(){


printf("=======stack=========\n");

for(int i = 0; i<SIZE ; i++)

{

printf("%d ",st[i]);

}

printf("\n=====================\n");



}


int main()

{

int s,c;

Init();


for(;;)

{

printf("1.push 2.pop 3.view\n");

scanf("%d",&s);

if(s==1)

{

printf("입력할 숫자를 쓰세요\n");

scanf("%d",&c);

push(c);

}

else if(s==2)

{

pop();

}

else{

view();

}

}

return 0;

}

*/






























/*

#include <stdio.h>

#define SIZE 1000

int st[SIZE]={};

int top;


int ini()

{

top = -1;

}

void push(int c)

{

if(top == SIZE-1)

{


return;

}

top++;

st[top] = c;

}

void pop()

{

if(top == -1)

{

return;

}

printf("%d ",st[top]);

top--;

}


int main()

{

int n,k;

scanf("%d",&n);

for(int i = 0; i < n; i++)

{

scanf("%d",&k);

push(k);

}

for(int j = 0; j < n; j++)

{

pop(k);

}


return 0;

}

*/

/*

#include <stdio.h>

#include <string.h>

#define SIZE 11


int st[SIZE];

int top;


void init()

{

top = -1;

}

void push(int c)

{

if(top == SIZE - 1)

{

return;

}

top++;

st[top] = c;

}

int pop()

{

if(top == -1)

{

return;

}

printf("%d",st[top]);

st[top]=0;

top--;

}


int main()

{

char str[11];

gets(str);

for(int i=0;i<strlen(str); i++)

{

push(str[i]-48);

}

for(int j=0; j<strlen(str); j++)

{

pop();

}

return 0;

}

*/

/*

#include <stdio.h>

#define SIZE 101


int st[SIZE] = {};

int top;


void init()

{

top = -1;

}

void push(int c)

{

if(top == SIZE - 1)

{

return;

}


if(c==0)

{

pop();

return ;

}

else

{

top++;

st[top] = c;

}


}

void pop()

{

if(top == -1)

{

return;

}

st[top] = 0;

top--;

}


void summ()

{

int s=0;

for(int i = 0; i <= top; i++)

{

s+=st[i];

}

printf("%d",s);

}


int main()

{

int n, k, sum;

init();

scanf("%d",&n);

for(int i = 0; i < n; i++)

{

scanf("%d",&k);

push(k);

}

summ();

return 0;

}

*/

댓글 0개
0
댓글
댓글 0개
유사 게시물
  • 20200919JAVA STACK
  • 20200924 stack
  • 20200925 stack -0
주소 : 경기도 용인시 광교중앙로 302 블루 스퀘어 602호
연락처 : 031) 216 - 1546
사업자등록번호 : 465-92-00916
​학원 등록 제 4603호