Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <fstream>
  2. #include <string>
  3. #include <sstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     ifstream in("INPUT.txt");
  10.     ofstream out("OUTPUT.txt");
  11.     unsigned a;
  12.     string sum("7182818284590452353602875");
  13.     in >> a;
  14.     if(a == 0)
  15.         out << 3;
  16.     else
  17.     {
  18.         int temp, temp2;
  19.         string str = sum.substr(a,1);
  20.         string str2 = sum.substr(a-1,1);
  21.         stringstream stream(str);
  22.         stream >> temp >> str;
  23.         stringstream stream2(str2);
  24.         stream2 >> temp2 >> str2;
  25.         if(temp >= 5 && a!=sum.size())
  26.         {
  27.             temp2++;
  28.             ostringstream stream3;
  29.             stream3 << temp2;
  30.             str = stream3.str();
  31.             sum.replace(a-1,1,str);
  32.         }
  33.         sum.erase(a,sum.size());
  34.         out << "2." << sum;
  35.  
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement