提交时间:2023-10-12 13:44:23
运行 ID: 106524
#include<bits/stdc++.h> using namespace std; int x,y; int i,j; char ab[100001],bc[100001]; int a[100001],b[100001]; int jw; int maxn,maxj; int main(){ cin>>ab>>bc; x=strlen(ab); y=strlen(bc); for(i=0;i<x;i++) a[i]=ab[x-i-1]-'0'; for(i=0;i<y;i++) b[i]=bc[y-i-1]-'0'; maxn=max(x,y); for(i=0;i<maxn;i++){ if(a[i] - b[i] < 0 || a[i] < 0){ a[i]=a[i]+10; a[i+1] = a[i+1] - 1; } a[i]=a[i]-b[i]; } int flag = 0; for(i=maxn-1;i>=0;i--){ if(flag == 0 && a[i] ==0){ continue; } cout<<a[i]; flag++; } return 0; }