Quantcast
Viewing all articles
Browse latest Browse all 39796

JULKA:spoj problem

can anyone please tell me what is wrong with this code..it give WA on spoj

include<bits stdc++.h="">

using namespace std; int main() { int l,m,t,i; char ta[101],ma[101]; int x[101],y[101]; for(int k=0;k<10;k++) { cin>>ta>>ma; l=strlen(ta); m=strlen(ma); int j=m-1,z,t=0; if((ta[l-1]%2==0 && ma[m-1]%2==0) || (ta[l-1]%2!=0 && ma[m -1]%2!=0)) { for(i=l-1;i>=0;i--) {
if(ta[i]<ma[j] &&="" j="">=0) { x[i]=((ta[i]-48)+10)-(ma[j]-48); ta[i-1]--; } else if(ta[i]>=ma[j] && j>=0) x[i]=(ta[i]-48)-(ma[j]-48); else x[i]=(ta[i]-48); j--;

}
x[l-1]/=2;
j=m-1;
for(i=l-1;i>=0;i--)
{
 if(j>=0)
    {
  z=x[i]+(ma[j]-48)+t;
  y[i]=z%10;
  t=z/10;
    }
    else if(j<0)
    {
    y[i]=x[i]+t;
    t=t/10;
    }
  j--;
}

for(i=0;i<l;i++)
{
    cout<<y[i];
}
cout<<"\n";
for(i=0;i<l;i++)
cout<<x[i];
//t--;

//else } cout<<"\n"; } }


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>