• 大小: 236KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-07
  • 语言: 其他
  • 标签:

资源简介

强大的多功能科学计算器 包含了所有计算符号 计算、运行正常

资源截图

代码片段和文件信息

#include“BigInt.h“
BigInt::BigInt()
{
digital[0]=0;   
len=0;       //当前大整数的长度 
sign=0;         //符号为正
    isLegal=true;
}

BigInt::BigInt(qllong obj)
{
    if(obj<0)
    {sign=trueobj = -obj;}
    else sign =false;
    digital[0]=obj%base;len=0;
    while(obj/=base)
    {digital[++len] = obj%base;}
    isLegal=true;
}
BigInt::BigInt(const BigInt &obj)
{
for(len=0sign=obj.sign;len<=obj.len;len++)
digital[len]=obj.digital[len];
len--;
     isLegal=obj.isLegal;
}
BigInt& BigInt::operator =(const BigInt &obj)
{
for(len=0sign=obj.sign;len<=obj.len;len++)
digital[len]=obj.digital[len];
len--;
     isLegal=obj.isLegal;
return *this;
}
BigInt& BigInt::operator = (QString qstr)
{
int i=0jk;
    if(qstr[0]==‘-‘)
    {sign=1;}
else 
    {
        sign=0;
        if(qstr[0]==‘+‘)
            qstr.remove(01);
    }
    i=qstr.length();
for(i=i-baseLENk=0;i>=sign;i-=baseLEN++k)
{
for(j=0digital[k]=0;jseLEN;++j)
        {
            if(qstr[i+j]==‘ ‘)continue;
            digital[k]=digital[k]*10+qstr[i+j].toAscii()-‘0‘;
        }
}
i+=baseLEN;
for(j=signdigital[k]=0;j    {
        if(qstr[j]==‘ ‘)continue;
        digital[k]=digital[k]*10+qstr[j].toAscii()-‘0‘;
    }
if(i==sign)k--;
len=k;
    isLegal=true;
return *this;
}
BigInt BigInt::operator +(const BigInt &obj)
{
BigInt sum;
if(obj.sign==sign)
{ //同号加;
int carry=0i;
for(i=0;i<=len && i <= obj.len;i++)
{
carry = carry +digital[i]+obj.digital[i];
sum.digital[i] = carry%base;
carry= carry/base;
}
for(;i<=len;i++)
{carry = carry + digital[i] sum.digital[i] = carry%base carry/=base;}
for(;i<=obj.len;i++)
{carry = carry +obj.digital[i] sum.digital[i] = carry%basecarry =carry/base;}
if(carry&&i        else if(carry&&i==MAXN){isLegal=false;return *this;}
else sum.len=i-1;
sum.sign = sign;
return sum;
}
else 
{ //异号变同号减法;
sum = obj;sum.sign= !sum.sign;
return *this-sum;
}
}
BigInt BigInt::operator +(int n)
{
if(n==0)
return *this;
if((sign==1&&n<0)||(sign==0&&n>0))
{
int tempcarry=0i=0;
if(n<0)n=-n;
BigInt sum;
if(len==0&&n>=base){digital[1]=0;}  
do
{
temp=n%base;n/=base;
carry+=digital[i]+temp;
sum.digital[i]=carry%base;
carry= carry/base;
i++;
}while(n);
while(i<=len)
{
carry+=digital[i];
sum.digital[i]=carry%base;
carry=carry/base;
i++;
}
if(carry&&i        else if(carry&&i==MAXN){isLegal=false;return *this;}
else sum.len=i-1;
sum.sign=sign;
return sum;
}
else
{
n=-n;
return *this-n;
}
}
BigInt BigInt::operator -(const BigInt &obj)
{
const BigInt *sub1*sub2;
BigInt quotient;
if(sign==obj.sign)
{ //同号减;
int i carry=0;
i = this->Cmp(obj1);                //绝对值比较;
if(i==0)
return quotient;                 //返回一个零
else i

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-04-24 15:36  Calculator\
     文件       15977  2012-09-09 22:51  Calculator\BigInt.cpp
     文件        1967  2012-08-25 21:34  Calculator\BigInt.h
     文件       57992  2012-12-18 13:15  Calculator\Calc.cpp
     文件        6177  2012-12-18 13:21  Calculator\Calc.h
     文件       40743  2012-12-18 13:13  Calculator\Calculator.cpp
     文件        3302  2012-11-01 00:33  Calculator\Calculator.h
     文件         708  2012-11-02 23:00  Calculator\Calculator.pro
     文件        7957  2013-04-24 15:35  Calculator\Calculator.pro.user
     文件       28244  2012-12-18 19:56  Calculator\Calculator.pro.user.2.5pre1
     文件       10104  2012-11-19 16:31  Calculator\ChildWindow.cpp
     文件        1314  2012-11-01 00:35  Calculator\ChildWindow.h
     文件       35133  2012-12-12 21:33  Calculator\Chinese.qm
     文件      119913  2012-12-12 21:34  Calculator\Chinese.ts
     文件        6098  2012-11-10 19:22  Calculator\Complex.cpp
     文件        1247  2012-11-10 19:22  Calculator\Complex.h
     文件        8795  2012-11-10 16:59  Calculator\GeneticAlgorithm.cpp
     文件         766  2012-11-10 16:47  Calculator\GeneticAlgorithm.h
     文件       13804  2012-10-30 14:31  Calculator\HugeCalc.cpp
     文件        1148  2012-10-18 15:28  Calculator\HugeCalc.h
     文件        4634  2013-04-24 15:35  Calculator\about.ui
     文件      155859  2012-11-17 22:56  Calculator\calculator.ui
     文件       14598  2012-12-18 13:13  Calculator\constant.ui
     文件        3462  2012-10-31 23:45  Calculator\history.ui
     文件       33831  2012-11-17 22:54  Calculator\hugeCalc.ui
     目录           0  2013-04-24 15:36  Calculator\images\
     文件       67168  2012-08-16 22:51  Calculator\images\banben.png
     文件        1092  2012-08-09 23:12  Calculator\images\clear.png
     文件         909  2012-07-25 16:08  Calculator\images\fold.png
     文件        1135  2012-04-27 03:45  Calculator\images\go-previous.png
     文件        5149  2012-04-27 03:46  Calculator\images\qt-logo.png
............此处省略19个文件信息

评论

共有 条评论