메뉴 건너뛰기

Programing

Code Up

3023

관리자 2020.04.06 19:42 조회 수 : 60

C++

#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

int first[10010],secend[10010],buho=0,buho2=0,e=0;

int i=0,cnt=0,cnt2=0;

char str[110];

void reverseString(char* s) {

  size_t size_ = strlen(s);

  char temp;

 

  for (size_t i = 0; i < size_ / 2; i++) {

    temp = s[i];

    s[i] = s[(size_ - 1) - i];

    s[(size_ - 1) - i] = temp;

  }

  if(e==0&&buho==1){

    s[size_-1]='\0';

  }

  if(e==1&&buho2==1)

    s[size_-1]='\0';

}

int main()

{

    scanf("%s",str);

    if(str[0]=='-'){

        buho++;

    }

    reverseString(str);

    while(str[i]!='\0'){

        first[i]=(int)str[i]-48;

        cnt++;

        i++;

    }

    scanf("%s",str);

    if(str[0]=='-'){

        buho2++;

    }

    e=1;

    reverseString(str);

    i=0;

    while(str[i]!='\0'){

        int c=(int)str[i]-48;

        for(int j=0;j<=cnt;j++){

            secend[j+i]+=first[j]*c;

        }

        cnt2++;

        i++;

    }

    buho+=buho2;

    for(int j=1;j<=10009;j++)

    {

        secend[j]+=secend[j-1]/10;

        secend[j-1]=secend[j-1]%10;

    }

    int a=1;

    for(int j=10009;j>=0;j--)

    {

        if(a==1&&secend[j]!=0){

            a=0;

        }

    }

    if(a==1){

        printf("0");

        return 0;

    }

    a=1;

    if(buho==1){

        printf("-");

    }

    for(int j=10009;j>=0;j--)

    {

        if(a==1&&secend[j]!=0){

            a=0;

        }

        if(a==1&&secend[j]==0)

            continue;

        printf("%d",secend[j]);

    }

 

    return 0;

}

 

번호 제목 글쓴이 날짜 조회 수
공지 안내사항 관리자 2019.12.02 175
172 3703 관리자 2019.12.20 8
171 3701 관리자 2019.12.20 9
170 3520 관리자 2019.12.20 8
169 3120 관리자 2019.12.20 8
» 3023 관리자 2020.04.06 60
167 3022 관리자 2020.04.06 51
166 3021 관리자 2020.04.06 63
165 3009 관리자 2019.12.20 8
164 3008 관리자 2019.12.20 6
163 3007 관리자 2019.12.20 7
162 3006 관리자 2019.12.20 14
161 2748 관리자 2019.12.20 9
160 2657 관리자 2019.12.20 21
159 2652 관리자 2019.12.20 7
158 2641 관리자 2019.12.20 7
157 2634 관리자 2019.12.20 6
156 1953 관리자 2019.12.20 7
155 1936 관리자 2019.12.20 7
154 1925 관리자 2019.12.20 7
153 1525 관리자 2019.12.20 9
152 1505 관리자 2019.12.20 7
151 1476 관리자 2019.12.20 3
150 1162 관리자 2019.12.20 7
149 1161 관리자 2019.12.20 7
148 1160 관리자 2019.12.20 7
147 1159 관리자 2019.12.20 5
146 1158 관리자 2019.12.20 5
145 1157 관리자 2019.12.20 10
144 1156 관리자 2019.12.20 7
143 1155 관리자 2019.12.20 5
위로