fork download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. const double p = 1.1;
  7.  
  8. string foo(const string& x) {
  9. double n_v = stod(x) * p;
  10. ostringstream strs;
  11. strs << n_v;
  12. return strs.str();
  13. }
  14.  
  15. int main() {
  16. string out;
  17. string buff;
  18. char tmp;
  19. int state = 0;
  20. while ((tmp = getchar()) != char_traits<char>::eof()) {
  21. if (state == 0) {
  22. if (isdigit(tmp)) {
  23. buff += tmp;
  24. state = 1;
  25. }
  26. else {
  27. out += tmp;
  28. }
  29. }
  30. else if (state == 1) {
  31. if (isdigit(tmp)) {
  32. buff += tmp;
  33. }
  34. else if (tmp == '.') {
  35. buff += '.';
  36. state = 2;
  37. }
  38. else {
  39. out += foo(buff);
  40. out += tmp;
  41. buff.clear();
  42. state = 0;
  43. }
  44. }
  45. else {
  46. if (isdigit(tmp)) {
  47. buff += tmp;
  48. }
  49. else {
  50. out += foo(buff);
  51. out += tmp;
  52. buff.clear();
  53. state = 0;
  54. }
  55. }
  56. }
  57.  
  58. if (!buff.empty()) {
  59. out += foo(buff);
  60. buff.clear();
  61. state = 0;
  62. }
  63.  
  64. cout << out;
  65. return 0;
  66. }
Success #stdin #stdout 0s 16072KB
stdin
 {"Socker":0.8211111111111111111111111111111111,"
                                           Love you":3.20                
stdout
 {"Socker":0.903222,"
                                           Love you":3.52