Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Dec 6th, 2018 55 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. #include <stdio.h>
  2. #define MAXL 100
  3.  
  4. int strlen(char*);
  5. double str2double(char*);
  6.  
  7. int main()
  8. {
  9.     int i, j;
  10.     char str[MAXL];
  11.     char w[MAXL];
  12.     scanf("%s", str);
  13.     for (i = 0; str[i] != '\0'; ++i)
  14.     {
  15.         while ((str[i] == ' ' || str[i] == '\n') && str[i] != '\0') ++i;
  16.         j = 0;
  17.         while (str[i] != ' ' && str[i] != '\n' && str[i] != '\0') { w[j] = str[i]; ++j; ++i; }
  18.         w[j] = '\0';
  19.         printf("%.10g%s", str2double(w), "\n");
  20.         w[0] = '\0';
  21.     }
  22.  
  23.     return 0;
  24. }
  25.  
  26. int strlen(char* s)
  27. {
  28.     int i = 0;
  29.     while (s[i] != '\0') ++i;
  30.     return i;
  31. }
  32.  
  33. double str2double(char* s)
  34. {
  35.     double tens = 1, res = 0;
  36.     int i;
  37.     for (i = 0; i < strlen(s) && s[i] != '.'; ++i)
  38.         res = 10 * res + s[i] - '0';
  39.     for (++i; i < strlen(s); ++i)
  40.     {
  41.         tens /= 10;
  42.         res += tens * (s[i] - '0');
  43.     }
  44.     return res;
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top