Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     setlocale(LC_ALL, ".1251");
  9.  
  10.     char* firstNum = new char[255];
  11.     char* secondNum = new char[255];
  12.     char* answer = new char[300];
  13.  
  14.     cout << "Enter first BigNum: ";
  15.     cin.getline(firstNum, 255);
  16.  
  17.     for (int i = 0; i < strlen(firstNum); i++)
  18.     {
  19.         if (isalpha(firstNum[i]))
  20.         {
  21.             cout << "Wrond first BigNum!\n";
  22.             return 1;
  23.         }
  24.     }
  25.  
  26.     cout << "Enter second BigNum: ";
  27.     cin.getline(secondNum, 255);
  28.  
  29.     for (int i = 0; i < strlen(secondNum); i++)
  30.     {
  31.         if (isalpha(secondNum[i]))
  32.         {
  33.             cout << "Wrond second BigNum!\n";
  34.             return 1;
  35.         }
  36.     }
  37.  
  38.     bool firstMore = false;
  39.     int firstLen = strlen(firstNum) - 1, secondLen = strlen(secondNum) - 1;
  40.    
  41.     if (firstLen - secondLen >= 0)
  42.         firstMore = true;
  43.  
  44.     if (firstMore)
  45.     {
  46.         _asm
  47.         {
  48.             mov eax, 0; десяток
  49.             mov ecx, 0; итерактивная сумма
  50.             mov esi, firstNum
  51.             mov edi, secondNum
  52.             mov eci, answer;
  53.             add esi, firstLen
  54.             add edi, secondLen
  55.  
  56.             _start:
  57.                 cmp edi, 0
  58.                     je _fillEmpty
  59.                 add ecx, [esi]
  60.                 add ecx, [edi]
  61.                 add ecx, eax
  62.                 cmp ecx, 10
  63.                     jg _greater
  64.                     jmp _lower
  65.             _greater:
  66.                 mov AL, ecx
  67.                 mov BL, 10
  68.                 DIV BL
  69.                 mov [eci], BL
  70.                 DEC eci
  71.                 DEC esi
  72.                 DEC edi
  73.                 add eax, AL
  74.                 jmp _start
  75.  
  76.             _lower:
  77.                 mov [eci], ecx
  78.                 mov eax, 0
  79.                 DEC eci
  80.                 DEC esi
  81.                 DEC edi
  82.                 jmp _start
  83.  
  84.             _fillEmpty:
  85.                 cmp esi, 0
  86.                     jg _fill
  87.                 jmp _exit
  88.  
  89.             _fill:
  90.                 mov [eci], [esi]
  91.                 DEC eci
  92.                 DEC esi
  93.                 jmp _fillEmpty
  94.  
  95.             _exit:
  96.         }
  97.     }
  98.  
  99.    
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement