fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. cout.setf(ios::fixed);
  6. cout.precision(6);
  7.  
  8. double x;
  9. cin>>x;
  10. int n;
  11. cin>>n;
  12. string typ;
  13.  
  14. for (int i=0; i<n; i++){
  15. cin>>typ;
  16. if (typ=="int")
  17. cout<<int(x)<<endl;
  18. if (typ=="long")
  19. cout<<long(x)<<endl;
  20. if (typ=="double")
  21. cout<<double(x)<<endl;
  22. if (typ=="float")
  23. cout<<float(x)<<endl;
  24.  
  25. }
  26. return 0;
  27. }
Success #stdin #stdout 0s 3476KB
stdin
3.14
4
int
long
float
double
stdout
3
3
3.140000
3.140000