fork(1) download
  1.  
  2.  
  3. #include<cstdio>
  4. #include<cstdlib>
  5. #include<vector>
  6. #include<string>
  7. #include<iostream>
  8. #include<algorithm>
  9. using namespace std;
  10. int main()
  11. {
  12. vector<char> V;
  13. string S;
  14. int i=0;
  15. float f=3.14156;
  16. float x=f*1e6;
  17. long long int y=(long long int)(x);
  18. while(y)
  19. {
  20. V.push_back(y%10+'0');
  21. y/=10;
  22. }
  23. reverse(V.begin(),V.end());
  24. for(i=0;i<V.size()-6;i++)
  25. {
  26. S.push_back(V[i]);
  27. }
  28. S.push_back('.');
  29. for(;i<V.size();i++)
  30. S.push_back(V[i]);
  31.  
  32. i=S.size();
  33. while(i--)
  34. {
  35. if(S[i]=='0')
  36. S.erase(S.begin()+i);
  37. else break;
  38. }
  39. cout<<S<<"\n";
  40. //system("pause");
  41. return 0;
  42. }
Success #stdin #stdout 0s 2820KB
stdin
Standard input is empty
stdout
3.14156