makrusak

Это помощь Насте, потому что я её люблю :)

Nov 24th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <iostream>
  4. #include <algorithm>
  5. #include <vector>
  6. #include <string>
  7. #include <string.h>
  8. #include <queue>
  9. #include <stack>
  10. #include <deque>
  11. #include <map>
  12. #include <set>
  13. #include <cmath>
  14. #include <sstream>
  15. #include <ctime>
  16.  
  17. #define pb push_back
  18. #define mp make_pair
  19. #define PI 3.1415926535897932384626433832795
  20. #define ALL(x) x.begin(), x.end()
  21. #define F first
  22. #define S second
  23. #define m0(x) memset(x,0,sizeof(x))
  24. #define m1(x) memset(x,-1,sizeof(x))
  25. #define pw(x) (1ull<<(x))
  26.  
  27. using namespace std;
  28. typedef long long ll;
  29. typedef unsigned long long ull;
  30. typedef long double ld;
  31. typedef pair<int,int> pii;
  32. const int INF = 2147483647;
  33. const ll LLINF = 9223372036854775807LL;
  34.  
  35. //фу, плохой код, ужасный
  36. double perevod(char *str) {
  37.   double ans = 0;
  38.   while (*str>='0' && *str<='9') {
  39.     ans=ans*10+*str-'0';
  40.     str++;
  41.   }
  42.   if (*str=='.') {
  43.     double del = 1;
  44.     str++;
  45.     while (*str>='0' && *str<='9') {
  46.       del*=0.1;
  47.       ans+=(*str-'0')*del;
  48.       str++;
  49.     }
  50.   }
  51.   return ans;
  52. }
  53.  
  54. int main() {
  55.   //freopen("input.txt", "r", stdin);
  56.   //freopen("output.txt", "w", stdout);
  57.   char str[100];
  58.   gets(str);
  59.   printf("%.10lf\n", perevod(str));
  60.   return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment