include [HTML_REMOVED]
include[HTML_REMOVED]
include[HTML_REMOVED]
using namespace std;
vector[HTML_REMOVED]A,B,C;
bool compare(vector[HTML_REMOVED]A,vector[HTML_REMOVED]B)
{
if(A.size()>B.size()) return true;
if(A.size()[HTML_REMOVED]=0)
{
if (A[i]>B[i]) return true;
else if(B[i]>A[i]) return false;
else i–;
}
return true;
}
vector[HTML_REMOVED] subtraction(vector[HTML_REMOVED]A,vector[HTML_REMOVED]B)
{
vector[HTML_REMOVED] C;
int t=0;
for(int i=0;i[HTML_REMOVED]=B.size()) cout<[HTML_REMOVED]0
{
if(C[i]!=0) break;
else C.pop_back();
i–;
}
return C;
}
int main()
{
string a,b;
cin>>a>>b;
for(int i=a.length()-1;i>=0;i–) A.push_back(a[i]-‘0’); //从低到高 放
for(int i=b.length()-1;i>=0;i–) B.push_back(b[i]-‘0’);
int i=0,t=0;
bool flag=compare(A,B);
if (flag) C=subtraction(A,B);
else C=subtraction(B,A);
if(!flag) cout<<’-‘;
for(int i=C.size()-1;i>=0;i–) cout<<C[i];
}
挖个坑以后来填 当指向形参B的指针越界时 貌似指针会指向实参B?
形参实际上是暂时覆盖掉实参的值?