Analysis: Water problem, mainly to pay attention to a few details.
#include <iostream>using namespace Std;char a[100005],a[100005];char b[100005],b[100005];void Process (char* p, int count,char* p2) {int Pos;bool is_real;int i=0,k=0,j;label:while (* (p+i)! = ' \ "&& * (p+i) = = ' 0 ') i++;if (* (p+i) = = ' + ') {p2[0]= ' 0 ', p2[1]= ' + '; return; For 0}if (* (p+i) = = '-') {p2[k++]= '-'; I++;goto label;} if (* (p+i) = = ' + ') {i++; Handles a positive goto label;} while (* (p+i)! = ' ' && * (p+i)! = '. ') p2[k++]=p[i],i++;if (* (p+i) = = ' + ') {p2[k]= '} '; return;} Is_real=false;for (j=count-1;j>i;j--) if (is_real | | p[j]!= ' 0 ') {if (!is_real) pos=j;p2[k+j-i]=p[j];is_real=true;} if (!is_real) p2[k]= ' n '; elsep2[k]= '. ', p2[k+pos-i+1]= ';} BOOL IsEqual () {Process (A,strlen (a), a); Process (B,strlen (b), b), if (!strcmp (a), return true;else return false;} int main () {while (scanf ("%s%s", A, b) ==2) {if (IsEqual ()) cout<< "YES" <<endl;else cout<< "NO" << Endl;} return 0;}
HDU ACM 2054 A = = B Water problem