Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.35 KB | None | 0 0
  1. #include<iostream>
  2. #include<conio.h>
  3. #include<windows.h>
  4. using namespace std;
  5.  
  6. char numerals[36] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D',
  7. 'E','F','G','H','I','J','K','L','M','N','O','P','Q','R',
  8. 'S','T','U','V','W','X','Y','Z'};
  9. void gotoxy(int x, int y);
  10. int getNum(char c);
  11. char getChar(int n);
  12. void clear(char num1[50]);
  13. int getLength(char num[50]);
  14. bool isZero(char num[50]);
  15. void print(char num1[50]);
  16. bool isInSystem(char c,int syst);
  17. void cinlong(char mas[50]);
  18. void copyNum(char a[50],char b[50]);
  19. void mult(char num1[50],char num2[50],char res[50],int syst);
  20. void reverse(char arr[50], int start, int end) ;
  21. void getFirstNumeralsNumber(char num1[50],char num2[50],int k);
  22. int compareNumbers(char num1[50],char num2[50]);
  23. void sumNum(char num1[50],char num2[50],char res[50],int syst);
  24. void plusOne(char num1[50],int syst);
  25. void minusNum(char num1[50],char num2[50],char res[50],int syst);
  26. void catOne(char num[50],int n);
  27. void power(char num1[50],int k,char res[50],int syst);
  28. void toDecimal(char num1[50],char num2[50],int syst);
  29. bool isValidNum(char ch);
  30. void divNum(char num1[50],char num2[50],char resDiv[50],char ost[50],int syst);
  31. void decToN(char num1[50],char res[50],int n);
  32. int getCountNum(int a);
  33. int makeSpaces(int a);
  34. void printRes(char num1[50],char num2[50],char res[50],int syst,char op);
  35. bool isNumInSystem(char num[50],int syst);
  36. void myScanfSyst(int& syst);
  37. void myScanf(char num[50]);
  38.  
  39.  
  40.  
  41. int main()
  42. {
  43. char num1[50],num2[50],res[50],
  44. buf[50],buf1[50],buf2[50],resBuf[50],count[50],
  45. prevResBuf[50],copyNum1[50],resDiv[50];
  46. int len1 = 0,
  47. len2 = 0,
  48. len3 = 0,
  49. len4 = 0;
  50. int syst = 0;
  51. while(true)
  52. {
  53. syst = 0;
  54. clear(res);
  55. cout << "num1: \n";
  56. fflush(stdin);
  57. myScanf(num1);
  58. cout << "num2: \n";
  59.  
  60. myScanf(num2);
  61. cout << "syst: \n";
  62. myScanfSyst(syst);
  63. if(!isNumInSystem(num1,syst)) cout << "num1 isn't correct\n";
  64. if(!isNumInSystem(num2,syst)) cout << "num2 isn't correct\n";
  65. if(isNumInSystem(num1,syst) && isNumInSystem(num2,syst)) break;
  66. }
  67.  
  68.  
  69. while(1)
  70. {
  71. int item = 1;
  72. char ans = ' ';
  73. while((int)ans != 13)
  74. {
  75. system("cls");
  76. cout << "\t\t"<<"Menu"<<endl<<endl;
  77. cout << "num1:";
  78. print(num1);
  79. cout << endl;
  80. cout<<"num2:";
  81. print(num2);
  82. cout << endl;
  83. cout<<"syst:";
  84. cout << syst<<endl;
  85. cout<<endl;
  86. cout << "1 - plus";
  87. if(item == 1) cout<<"<-" <<endl; else cout << endl;
  88. cout << "2 - minus";
  89. if(item == 2) cout<<"<-" <<endl; else cout << endl;
  90. cout << "3 - multiplication";
  91. if(item == 3) cout<<"<-" <<endl; else cout << endl;
  92. cout << "4 - division";
  93. if(item == 4) cout<<"<-" <<endl; else cout << endl;
  94. cout << "5 - change first number";
  95. if(item == 5) cout<<"<-" <<endl; else cout << endl;
  96. cout << "6 - change number system";
  97. if(item == 6) cout<<"<-" <<endl; else cout << endl;
  98. cout << "7 - exit";
  99. if(item == 7) cout<<"<-" <<endl; else cout << endl;
  100. ans = getch();
  101. switch(ans)
  102. {
  103. case 72:
  104. {
  105. if(item == 1) item = 7; else item--;
  106. break;
  107. }
  108. case 80:
  109. {
  110. if(item == 7) item = 1; else item++;
  111. break;
  112. }
  113. }
  114. }
  115.  
  116.  
  117.  
  118. int mem = 0;
  119. int maxLen = 0;
  120. if(item == 1)
  121. {
  122. sumNum(num1,num2,res,syst);
  123. printRes(num1,num2,res,syst,'+');
  124.  
  125.  
  126.  
  127. system("pause>0");
  128. }
  129.  
  130. if(item == 2)
  131. {
  132. if(compareNumbers(num1,num2) >= 0)
  133. {
  134. minusNum(num1,num2,res,syst);
  135. printRes(num1,num2,res,syst,'-');
  136. }
  137. else
  138. {
  139.  
  140. cout << "first < second";
  141. }
  142.  
  143. system("pause>0");
  144. }
  145.  
  146. if(item == 3)
  147. {
  148.  
  149. mult(num1,num2,res,syst);
  150. printRes(num1,num2,res,syst,'*');
  151.  
  152. system("pause>0");
  153. }
  154.  
  155. if(item == 4)
  156. {
  157. char ost[50];
  158. divNum(num1,num2,res,ost,syst);
  159. printRes(num1,num2,res,syst,'\\');
  160.  
  161. system("pause>0");
  162. }
  163. if(item == 5)
  164. {
  165.  
  166.  
  167. system("cls");
  168.  
  169. print(num1);
  170. char ch = ' ';
  171. int len1 = getLength(num1);
  172. int curX = len1-1;
  173. gotoxy(curX,0);
  174. while((int)(ch = getch()) != 13)
  175. {
  176. if(ch == 75)
  177. {
  178. curX--;
  179. gotoxy(curX,0);
  180. }
  181. else if(ch == 77)
  182. {
  183. if(curX+1<=len1-1)
  184. {
  185. curX++;
  186. }
  187. gotoxy(curX,0);
  188. }
  189. else if(ch == 72)
  190. {
  191. if(num1[len1-1 - curX] < numerals[syst-1])
  192. {
  193. num1[len1-1 - curX] = getChar(getNum(num1[len1-1 - curX]) + 1);
  194. cout << num1[len1-1 - curX];
  195. }
  196.  
  197. //print(num1);
  198. gotoxy(curX,0);
  199. }
  200. else if(ch == 80)
  201. {
  202. if(num1[len1-1 - curX] > '0')
  203. num1[len1-1 - curX] = getChar(getNum(num1[len1-1 - curX]) - 1);
  204. cout << num1[len1-1 - curX];
  205. //print(num1);
  206. gotoxy(curX,0);
  207. }
  208. else if(isValidNum(ch))
  209. {
  210. if(ch != num1[len1 - 1 - curX])
  211. {
  212. num1[len1 - 1 - curX] = ch;
  213. cout << num1[len1 - 1 - curX];
  214. //print(num1);
  215. gotoxy(curX,0);
  216. }
  217. }
  218. else if ((ch >= 'A') && (ch <= numerals[syst-1]))
  219. {
  220. if(ch != num1[len1 - 1 - curX])
  221. {
  222. num1[len1 - 1 - curX] = ch;
  223. cout << num1[len1 - 1 - curX];
  224. gotoxy(curX,0);
  225. }
  226.  
  227. //print(num1);
  228.  
  229. }
  230. }
  231. gotoxy(0,1);
  232. }
  233. if(item == 6)
  234. {
  235. int t = 0;
  236. cout << "For num1: ";
  237. print(num1);
  238. cout << endl;
  239. cout << "For num2: ";
  240. print(num2);
  241. cout << endl;
  242. cout<<"Number System from "<<syst<<" to: ";
  243. cin>>t;
  244. toDecimal(num1,buf,syst);
  245. decToN(buf,res,t);
  246. cout << "num1: ";
  247. copyNum(num1,res);
  248. print(num1);
  249. cout << endl;
  250. toDecimal(num2,buf,syst);
  251. decToN(buf,res,t);
  252. copyNum(num2,res);
  253. cout << "num2: ";
  254. print(num2);
  255. cout << endl;
  256. syst = t;
  257. system("pause>0");
  258. }
  259. if(item == 7)
  260. {
  261. break;
  262. }
  263.  
  264. }
  265.  
  266.  
  267.  
  268.  
  269. return 0;
  270. }
  271.  
  272.  
  273.  
  274. int getNum(char c)
  275. {
  276. for(int i = 0;i<36;i++)
  277. {
  278. if(numerals[i] == c) return i;
  279. }
  280. }
  281. char getChar(int n)
  282. {
  283. return numerals[n];
  284. }
  285.  
  286. void clear(char num1[50])
  287. {
  288. for(int i = 0;i<50;i++)
  289. {
  290. num1[i] = '0';
  291. }
  292. }
  293.  
  294. int getLength(char num[50])
  295. {
  296. int i = 49;
  297. while(num[i--]=='0');
  298.  
  299. i++;
  300. return i+1;
  301. }
  302. bool isZero(char num[50])
  303. {
  304. for(int i = 49;i>=0;i--)
  305. {
  306. if(num[i] != '0') return false;
  307. }
  308. return true;
  309. }
  310.  
  311. void print(char num1[50])
  312. {
  313. if(isZero(num1)) cout << "0";
  314. else
  315. {
  316. int i = 49;
  317. while(num1[i--] == '0');
  318. i++;
  319. for(i;i>=0;i--)
  320. {
  321. cout << num1[i];
  322. }
  323. }
  324. }
  325.  
  326. bool isInSystem(char c,int syst)
  327. {
  328. for(int i = 0;i<syst;i++)
  329. {
  330. if(c == numerals[i]) return true;
  331. }
  332. return false;
  333. }
  334. bool isNumInSystem(char num[50],int syst)
  335. {
  336. int len = getLength(num);
  337. //cout << "*";
  338. //for(int i = 0;i<50;i++) cout << num[i];
  339. //cout << "*";
  340. //cout << endl;
  341. //cout << "len = "<<len<<endl;
  342. int k = 0;
  343. for(int j = 0;j<len;j++)
  344. {
  345. for(int i = 0;i<syst;i++)
  346. {
  347. if(num[j] == numerals[i]) {k++;break;}
  348. }
  349. }
  350. //cout << "k = "<<k<<endl;
  351. if(k != len) return false;
  352. return true;
  353. }
  354.  
  355. void myScanfSyst(int& syst)
  356. {
  357. char a[50] = {0};
  358. char num[50] = {0};
  359. int len = 0;
  360. while(true)
  361. {
  362. len = 0;
  363. while((a[len] = (getchar()))!= '\n')
  364. {
  365. len++;
  366. }
  367. for(int i=0;i<50;++i) num[i] = '0';
  368. for(int i=0;i<len;i++)
  369. {
  370. num[len - i - 1] = a[i];
  371. }
  372. //cout << "isNumInSystem(num,10) = "<<isNumInSystem(num,10)<<endl;
  373. //cout << "atoi(a) = "<<atoi(a)<<endl;
  374. if(!isNumInSystem(num,10) || ((atoi(a) < 2) || (atoi(a) > 36))) cout << "not correct\n";
  375. else break;
  376. }
  377. syst = atoi(a);
  378. }
  379.  
  380. void cinlong(char mas[50])
  381. {
  382. string s;
  383. cin >> s;
  384. for(int i=0;i<50;++i)
  385. mas[i] = '0';
  386.  
  387. int len = s.length();//method class string
  388. for(int i=0;i<len;i++)
  389. mas[len - i - 1] = (s[i]);
  390. }
  391. void copyNum(char a[50],char b[50])
  392. {
  393. for(int i = 0;i<50;i++) a[i] = b[i];
  394. }
  395.  
  396.  
  397. void reverse(char arr[50], int start, int end)
  398. {
  399. char temp;
  400. while (start < end)
  401. {
  402. temp = arr[start];
  403. arr[start] = arr[end];
  404. arr[end] = temp;
  405. start++;
  406. end--;
  407. }
  408. }
  409.  
  410.  
  411.  
  412.  
  413. void mult(char num1[50],char num2[50],char res[50],int syst)
  414. {
  415. int resBuf[50] = {0};
  416. for (int i = 0; i < 50; i++)
  417. {
  418. for (int j = 0; j < 50; j++)
  419. {
  420. if(i+j<50)
  421. resBuf[i + j] += (getNum(num1[i])) * (getNum(num2[j]));
  422. }
  423. }
  424. for (int i = 0; i < 50-1; i++)
  425. {
  426. resBuf[i + 1] += (resBuf[i] / syst);
  427. resBuf[i]= resBuf[i] % syst;
  428. }
  429. for(int i = 0;i<50;i++) res[i] = getChar(resBuf[i]);
  430. }
  431.  
  432.  
  433. void getFirstNumeralsNumber(char num1[50],char num2[50],int k)
  434. {
  435. int i = 49;
  436. while(num1[i--]=='0');
  437.  
  438. i++;
  439. k--;
  440. clear(num2);
  441. for(int j = i;j>=i-k;j--)
  442. {
  443. num2[i-j] = num1[j];
  444. }
  445. reverse(num2,0,k);
  446. }
  447.  
  448. int compareNumbers(char num1[50],char num2[50])
  449. {
  450. if(getLength(num1) > getLength(num2)) return 1;
  451. else if(getLength(num2) > getLength(num1)) return -1;
  452. else
  453. {
  454. for(int i = getLength(num1);i>=0;i--)
  455. {
  456. if(num1[i] > num2[i]) return 1;
  457. else if(num2[i] > num1[i]) return -1;
  458. }
  459. return 0;
  460. }
  461. }
  462.  
  463. void sumNum(char num1[50],char num2[50],char res[50],int syst)
  464. {
  465. int mem = 0;
  466. int maxLen = max(getLength(num1),getLength(num2));
  467. for(int i = 0;i<=maxLen;i++)
  468. {
  469. res[i] = getChar((getNum(num1[i]) + getNum(num2[i]) + mem)%syst);
  470. //res[i] = (((num1[i]-'0') + (num2[i]-'0') + mem)%syst)+'0';
  471. mem = (getNum(num1[i]) + getNum(num2[i]) + mem)/syst;
  472. }
  473. }
  474.  
  475.  
  476. void plusOne(char num1[50],int syst)
  477. {
  478. char num2[50];
  479. clear(num2);
  480. num2[0] = '1';
  481. int mem = 0;
  482. int maxLen = max(getLength(num1),1);
  483. for(int i = 0;i<=maxLen;i++)
  484. {
  485. int save = (getNum(num1[i]) + getNum(num2[i]) + mem);
  486. num1[i] = getChar((getNum(num1[i]) + getNum(num2[i]) + mem)%syst);
  487. mem = save / syst;
  488. }
  489.  
  490. }
  491. void minusNum(char num1[50],char num2[50],char res[50],int syst)
  492. {
  493. char buf[50];
  494. clear(buf);
  495. copyNum(buf, num1);
  496. int curSum = 0;
  497. int maxLen = max(getLength(num1),getLength(num2));
  498. for(int i = 0;i<=maxLen;i++)
  499. {
  500. if((getNum(num1[i])) < (getNum(num2[i])))
  501. {
  502. int j = i+1;
  503. while(num1[j] == '0') {num1[j] = numerals[syst-1];j++;}
  504.  
  505. num1[j] = getChar((getNum(num1[j]))-1);
  506. curSum = (getNum(num1[i])) + syst;
  507. res[i] = getChar(curSum - (getNum(num2[i])));
  508. }
  509. else res[i] = getChar(getNum(num1[i]) - getNum(num2[i]));
  510. }
  511. copyNum(num1,buf);
  512. }
  513. void catOne(char num[50],int n)
  514. {
  515. int len = getLength(num);
  516. for(int i = len-1;i>=0;i--)
  517. num[i+1] = num[i];
  518. num[0] = getChar(n);
  519. }
  520.  
  521.  
  522. void power(char num1[50],int k,char res[50],int syst)
  523. {
  524. clear(res);
  525. res[0] = '1';
  526. for(int i = 0;i<k;i++)
  527. {
  528. mult(res,num1,res,syst);
  529. }
  530.  
  531. }
  532.  
  533. void toDecimal(char num1[50],char num2[50],int syst)
  534. {
  535. char res[50],resBuf[50],powerBuf[50],copyRes[50];
  536. clear(resBuf);
  537. clear(powerBuf);
  538. clear(res);
  539. char num[50];clear(num);
  540. char systNum[50];clear(systNum);
  541. systNum[0] = numerals[syst];
  542. for(int i = 0;i<getLength(num1);i++)
  543. {
  544. clear(resBuf);
  545. clear(powerBuf);
  546. num[0] = num1[i];
  547. power(systNum,i,powerBuf,10);
  548. mult(powerBuf,num,resBuf,10);
  549. copyNum(copyRes,res);
  550. sumNum(copyRes,resBuf,res,10);
  551. }
  552. copyNum(num2,res);
  553. }
  554.  
  555. bool isValidNum(char ch)
  556. {
  557. if((ch == '0') || (ch == '1') || (ch == '2') || (ch == '3') || (ch == '4') || (ch == '5') || (ch == '6')
  558. || (ch == '7') || (ch == '8') || (ch == '9'))
  559. return true;
  560. return false;
  561. }
  562.  
  563.  
  564. void divNum(char num1[50],char num2[50],char resDiv[50],char ost[50],int syst)
  565. {
  566. clear(ost);
  567. clear(resDiv);
  568. char copyNum1[50],buf[50],resBuf[50],
  569. prevResBuf[50],res[50],
  570. count[50];
  571. clear(res);
  572. if(compareNumbers(num1,num2)>0)
  573. {
  574. clear(resDiv);
  575. copyNum(copyNum1,num1);
  576. int len1 = getLength(num1);
  577. int k = 0;
  578. int len2 = getLength(num2);
  579. clear(buf);
  580.  
  581. //cout << "buf: ";
  582. //print(buf);
  583. int cnt = 0;
  584. while(compareNumbers(buf,num2) < 0)
  585. {
  586.  
  587. getFirstNumeralsNumber(num1,buf,getLength(num2)+cnt);
  588. cnt++;
  589.  
  590. }
  591. if (cnt>1) len1--;
  592. while(1)
  593. {
  594.  
  595. clear(resBuf);
  596. clear(prevResBuf);
  597. if(k != 0)
  598. {
  599. //cout << "k+len2 = "<<k+len2<<endl;
  600. //cout << "len1+1 = "<<len1+1<<endl;
  601. if(k+len2 == len1+1) break;
  602. copyNum(buf,res);
  603. catOne(buf,getNum(copyNum1[len1 - (len2+k)]));
  604. }
  605. // cout << "buf:\n";
  606. // print(buf);
  607. clear(count);
  608. clear(prevResBuf);
  609. int cnt = 0;
  610. do
  611. {
  612. cnt++;
  613. copyNum(prevResBuf,resBuf);
  614. plusOne(count,syst);
  615. //cout << "count:\n";
  616. //print(count);
  617.  
  618. mult(count,num2,resBuf,syst);
  619. //cout << "resBuf:\n";
  620. //print(resBuf);
  621. //cout << "buf:\n";
  622. //print(buf);
  623. //system("pause>0");
  624.  
  625. }while(compareNumbers(resBuf,buf) <= 0);
  626. catOne(resDiv,cnt-1);
  627.  
  628. clear(res);
  629. //cout << " ";
  630. //print(buf);
  631. //cout<<"-"<<endl;
  632. //cout << " ";
  633. //print(prevResBuf);
  634. //cout<<"-----"<<endl;
  635. //cout << " ";
  636. minusNum(buf,prevResBuf,res,syst);
  637. //cout << "res:\n";
  638. //print(res);
  639. //print(res);
  640. k++;
  641. //system("pause>0");
  642.  
  643.  
  644. }
  645. //print(resDiv);
  646. copyNum(ost,res);
  647. //cout << "ost: "<<ost[0]<<ost[1]<<endl;
  648. char c = getChar(getNum(ost[1])*10+getNum(ost[0]));
  649. clear(ost);
  650. ost[0] = c;
  651. //print(ost);
  652.  
  653. }
  654. else if(compareNumbers(num1,num2)==0)
  655. {
  656.  
  657. clear(resDiv);
  658. resDiv[0] = '1';
  659. //print(resDiv);
  660. clear(ost);
  661. }
  662. else {resDiv[0] = '0';copyNum(ost,num1);}
  663.  
  664. if(isZero(resDiv)) ;//cout << "0";
  665.  
  666. }
  667.  
  668. void decToN(char num1[50],char res[50],int n)
  669. {
  670. char num2[50],buf[50],resDiv[50];
  671. clear(num2);
  672. num2[0] = numerals[n];
  673.  
  674. clear(res);
  675. char ost[50];
  676. clear(ost);
  677. clear(buf);
  678. int k = 0;
  679. do
  680. {
  681. clear(ost);
  682. divNum(num1,num2,resDiv,ost,10);
  683. copyNum(num1,resDiv);
  684. int len = getLength(ost);
  685. if(len == 0) {buf[k] = '0';k++;}
  686. for(int i = len-1;i>=0;i--)
  687. {
  688. buf[k] = ost[i];
  689. k++;
  690. }
  691.  
  692. }while(compareNumbers(resDiv,res) != 0);
  693.  
  694. copyNum(res,buf);
  695.  
  696.  
  697. }
  698. int getCountNum(int a)
  699. {
  700. int cnt = 0;
  701. while(a > 0)
  702. {
  703. a /= 10;
  704. cnt++;
  705. }
  706. return cnt;
  707. }
  708.  
  709. int makeSpaces(int a)
  710. {
  711. for (int i = 0;i<a;i++)
  712. {
  713. cout << " ";
  714. }
  715. }
  716.  
  717.  
  718. void printRes(char num1[50],char num2[50],char res[50],int syst,char op)
  719. {
  720. char buf[50],buf1[50],buf2[50];
  721. cout << "("<<syst<<") ";
  722. print(num1);
  723. //--------------------------------------
  724. cout <<"\t\t\t("<<10<<") ";
  725. //-----------print num1 in decimal---------
  726. toDecimal(num1,buf,syst);
  727. print(buf);
  728. cout << endl;
  729. //-------------
  730.  
  731. makeSpaces(getCountNum(syst)+2);
  732. cout<<op<<"\t\t\t";
  733. makeSpaces(getCountNum(syst)+3+getCountNum(10)+2+getLength(num1));
  734. cout<<endl;
  735. makeSpaces(getCountNum(syst)+3+abs(getLength(num1)-getLength(num2)));
  736. print(num2);
  737.  
  738. cout<<"\t\t\t";
  739. toDecimal(num2,buf2,syst);
  740. makeSpaces(getCountNum(10)+3+abs(getLength(buf)-getLength(buf2)));
  741. print(buf2);
  742. cout << endl;
  743.  
  744. makeSpaces(getCountNum(syst)+3);
  745.  
  746. for(int i = 0;i<getLength(num1);i++)
  747. cout<<"-";
  748. cout<<"\t\t\t";
  749. makeSpaces(getCountNum(10)+3);
  750. for(int i = 0;i<getLength(buf);i++)
  751. cout<<"-";
  752. cout<<endl;
  753.  
  754.  
  755.  
  756. makeSpaces(getCountNum(10)+3+abs(getLength(num1)-getLength(num2)));
  757. print(res);
  758. if(getLength(res) < getLength(num2))
  759. {
  760. makeSpaces(getCountNum(10)+3);
  761. for(int i = 0;i<getLength(num1)-1;i++) cout << " ";
  762. }
  763. cout<<"\t\t\t";
  764.  
  765. makeSpaces(getCountNum(10)+3+abs(getLength(buf)-getLength(buf2)));
  766. toDecimal(res,buf,syst);
  767. print(buf);
  768. }
  769. void gotoxy(int x, int y)
  770. {
  771. static HANDLE h = NULL;
  772. if(!h)
  773. h = GetStdHandle(STD_OUTPUT_HANDLE);
  774. COORD c = { x, y };
  775. SetConsoleCursorPosition(h,c);
  776. }
  777.  
  778. void myScanf(char num[50],char*num1,char*num2)
  779. {
  780. char a1[50] = {0};
  781. char a2[50] = {0};
  782. int len = 0;
  783. while(true)
  784. {
  785. len = 0;
  786. while((a1[len] = (getchar()))!= '\n')
  787. {
  788. a2[len] = a1[len];
  789. len++;
  790. }
  791. int k = 0;
  792. for(int i = 0;i < len; i++)
  793. {
  794. for(int j = 0;j<36;j++)
  795. {
  796. if(a2[i] >='a' && a2[i] <= 'z') a2[i] = a2[i] - 'a' + 'A';
  797. if(a2[i] == numerals[j]) {k++;break;}
  798. }
  799. }
  800. if(k != len) //ИЗМЕНЕНО НИЖЕ
  801. {
  802. cout << "not correct numerals\n";
  803. cout << "num1:";
  804. print(num1);
  805. cout << endl;
  806. cout<<"num2:";
  807. print(num2);
  808. cout << endl;
  809. } //
  810. else break;
  811. }
  812. for(int i=0;i<50;++i) num[i] = '0';
  813. for(int i=0;i<len;i++)
  814. {
  815. num[len - i - 1] = a2[i];
  816. }
  817. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement