提交时间:2023-10-14 08:47:20
运行 ID: 106675
#include<bits/stdc++.h> using namespace std; int main(){ int a[25600],b[25600],c[25600],lena,lenb,lenc,i; char n[10000],n1[50000],n2[25600]; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(c,0,sizeof(c)); gets(n1); gets(n2); if(strlen(n1)<strlen(n2) || (strlen(n1) == strlen(n2) && strcmp(n1,n2)<0)){ strcpy(n,n1); strcpy(n1,n2); strcpy(n2,n); cout<<"-"; } //wcnmd,sbc++,njsgdsb lena=strlen(n1); lenb=strlen(n2); for(i=0;i<=lena-1;i++){ a[lena-i]=int(n1[i]-'0'); } for(i=0;i<=lenb-1;i++){ b[lenb-i]=int(n2[i]-'0'); } i=1; while(i<=lena||i<=lenb){ if(a[i]<b[i]){ a[i]+=10; a[i+1]--; } c[i]=a[i]-b[i]; i++; } lenc=i; while((c[lenc]==0) && (lenc>1)){ lenc--; } for(i=lenc;i>=1;i--){ lenc--; } cout<<endl; return 0; }