ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1001. Reverse Root

Please HELP!!!
Posted by Akash Gangil 7 Aug 2009 20:55
Can anybody tell me what's wrong with this?
When I test the program it works fine.
I end the input using ctrl-D , Is that wrong?
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>

/*function to reverse a string*/
void strrev(char string[256])
{
 char reverse[256];
 int i,j;
 i=strlen(string);

 for (j=i-1;j>=0;j--)
  {
    reverse[i-1-j]=string[j];
  }
  reverse[i]='\0';
  strcpy(string,reverse);
}


int main(void)
{

 int k=0,i=0,j,different=0,start=0;
 int c;
 char stream[256];
 char num[256];
 char copy[256];
 double number;
 while((c=getchar())!=EOF)
  {
   stream[i]=c;
   j=i;
   i++;
  }

 for (k=j;k>=0;k--)
  {
   if(isdigit(stream[k])!=0)
     {
       if(isdigit(stream[k-1])!=0)
        {
          num[start]=stream[k];
          start++;
        }
       else
        {
          num[start]=stream[k];
          num[start+1]='\0';
//          printf("%s\n",num);
          strrev(num);
//          printf("%s\n",num);
          strcpy(copy,num);
          number=strtod(copy,NULL);
          printf("%0.4f\n",sqrt(number));
          start=0;

        }
     }
  }

  return 0;

}









Re: Please HELP!!!
Posted by goodstudent 22 Aug 2009 13:59