You are not logged in. Please login at www.codechef.com to post your questions!

×

run time error in spoj revres number

include<iostream>

include<algorithm>

include<stdio.h>

include<string>

include<math.h>

using namespace std; int main() { int num,i; int result[1000]; cin>>num; string s[1000]; for( i=0;i<num;i++) { fflush(stdin); getline(cin,s[i]); }

for( i=0;i<num;i++)

{

  string c=(" ");

 int found=s[i].find(c);




 string sub1,sub2;

sub1=s[i].substr(0,found ); sub2=s[i].substr(found+1,s[i].size());

   reverse(sub1.begin(),sub1.end());

reverse(sub2.begin(),sub2.end());

char s1=&sub1[0]; char s2=&sub2[0];

int s11=atoi(s1);

int s12=atoi(s2);

int sum=s11+s12;

int k=sum;

sum=0; double j=0; while(k!=0)

{ sum=sum*pow(10,1)+k%10; k=k/10; j++; }

result[i]=sum;

}

for(int i=0;i<num;i++) { cout<<result[i]<<endl;

}

return 0; }

asked 30 Mar '15, 12:55

ankit777's gravatar image

1★ankit777
4919
accept rate: 12%

a link to the problem, an explanation of your algorithm. and some proper formatting would be helpful

(30 Mar '15, 12:57) arun_as1★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,136
×532
×228
×27
×6

question asked: 30 Mar '15, 12:55

question was seen: 569 times

last updated: 30 Mar '15, 12:57