当前位置:   article > 正文

AtCoder Beginner Contest 196 ----- B(模拟)_given an integer or a decimal xx, round it down to

given an integer or a decimal xx, round it down to an integer and print the

Problem Statement

Given an integer or a decimal XX, round it down to an integer and print the result.

Constraints

  • 0≤X≤101000≤X≤10100
  • XX is an integer or a decimal with at most 100100 digits after the decimal point, without unnecessary leading zeros.

Sample Input 1 Copy

5.90

Sample Output 1 Copy

5

We round down 5.905.90 to an integer, 55, and print it as an integer. Non-integer outputs such as 5.0 will be judged as incorrect.

字符串存储

1 0的话直接输出

2 不是0的话找小数点之前的数,加到字符串t种

code:
 

  1. #include<bits/stdc++.h>
  2. #define INF 0x3f3f3f3f
  3. #define N 100003
  4. #define mod 100000
  5. #define pb push_back
  6. #define x first
  7. #define y second
  8. #define ull unsigned long long
  9. #define ll long long
  10. using namespace std;
  11. int a[N];
  12. int main()
  13. {
  14. ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  15. //freopen("in.txt", "r", stdin);
  16. //freopen("out.txt", "w", stdout);
  17. string s;
  18. cin >> s;
  19. if(s[0] == '0')
  20. {
  21. cout << 0 << endl;
  22. return 0;
  23. }
  24. string t;
  25. for(int i = 0;i < s.length();i++)
  26. {
  27. if(s[i] != '.')
  28. t += s[i];
  29. else
  30. break;
  31. }
  32. cout << t << endl;
  33. return 0;
  34. }

 

 

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/52695
推荐阅读
相关标签
  

闽ICP备14008679号