fork(1) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5.  
  6. int num[10005]; //chua cac so
  7.  
  8. bool isNumber (string s)
  9. {
  10. for (int i = 0; i < s.size(); i++)
  11. {
  12. if (isdigit(s[i]) == false) return false;
  13. }
  14. return true;
  15. }
  16. signed main()
  17. {
  18. ios_base::sync_with_stdio(0);
  19. cin.tie(0);
  20. cout.tie(0);
  21. string s;
  22. getline(cin,s);
  23. if (isNumber(s) == true)
  24. {
  25. int res = 0;
  26. for (int i = 0; i < s.size(); i++)
  27. {
  28. res = res*10 + (s[i] - '0');
  29. }
  30. cout << res;
  31. return 0;
  32. }
  33. int res = 0;
  34. int k = 0;
  35. for (int i = 0; i < s.size(); i++)
  36. {
  37. if (isdigit(s[i]) == true)
  38. {
  39. if (s[i - 1] == '-')
  40. {
  41. res = res*10 - (s[i] - '0');
  42. }
  43. else
  44. {
  45. res = res*10 + (s[i] - '0');
  46. }
  47. }
  48.  
  49. if (isdigit(s[i]) == false)
  50. {
  51. num[++k] = res;
  52. res = 0;
  53. }
  54. }
  55. int ans = 0;
  56. for (int i = 1; i <= k; i++)
  57. {
  58. ans = max(ans, num[i]);
  59. }
  60. cout << ans;
  61. return 0;
  62. }
  63.  
Success #stdin #stdout 0.01s 5380KB
stdin
Abc987hnmh0003456hs006543m
stdout
6543