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

200505

게시판: 소스 코드 제출

/*

#include <stdio.h>


#include <string.h>




int b=0;


int stack2[201];


void push2(int v)

{


stack2[b]=v;


b++;


}


int pop2()

{


b--;


return stack2[b];


}


int main()

{

char s[201];

int ret1=0,ret2=0,c=0;

gets(s);


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

{

if(!(s[i]=='*'||s[i]=='+'||s[i]=='-'))

{

if (c>0)

{

if (s[i]!=' ')

{

push2(pop2()*10+(s[i]-'0'));

c++;


}


else

{

c=0;

}

}


else

{

if (s[i]!=' ')

{

push2(s[i]-'0');

c++;

}

else

{

c=0;

}


}

}


else

{

ret1=pop2();


ret2=pop2();



if (s[i]=='*')

{

push2((ret1*ret2));

}


else if (s[i]=='+')

{

push2((ret1+ret2));

}


else

{

push2((ret2-ret1));

}


}


if (i==strlen(s)-1)

{

printf("%d",pop2());

}

}

return 0;

}


*/

















#include <stdio.h>


#include <string.h>

#include <math.h>


int a=0,b=0,c=0;

int stack1[103],stack2[103],stack3[103];


void push1(int x)

{

stack1[a]=x;

a++;

}


void push2(int y)

{

stack2[b]=y;

b++;

}


int pop1()

{

a--;

return stack1[a];

}


int pop2()

{

b--;

return stack2[b];

}


void push3(int z)

{

stack3[c]=z;

c++;

}


int pop3()

{

c--;

return stack3[c];

}



int main()

{

int i,x=0,y=0,k=0;

int len_c,len_d;

char c[102],d[102];


scanf("%s %s",c,d);

len_c = strlen(c);

len_d = strlen(d);


for (i=0; i<len_c; i++)

{

push1(c[i]-'0');

}


for (i=0; i<len_d; i++)

{

push2(d[i]-'0');

}



for (i = 0 ; i < (len_c>len_d?len_d:len_c) ; i++)

{

x+=pop1()+ pop2();

if (x<10)

{

push3(x);

x=0;

}

else

{

push3(x%10);

x=1;

}


}


////

for (i=0; i<abs(len_c-len_d); i++)

{

printf("%d",pop1());

}

////

for (i=0; i<len_d; i++)

{

printf("%d",pop3());

}


return 0;

}


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