Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int countDigits(int num) {
  6. int ans = 0;
  7. while (num > 0) {
  8. ++ans;
  9. num /= 10;
  10. }
  11. return ans;
  12. }
  13.  
  14. string itos(int num) {
  15. string ans = "";
  16. while (num > 0) {
  17. int digit = num % 10;
  18. ans += (digit + '0');
  19. num /= 10;
  20. }
  21. return ans;
  22. }
  23.  
  24. int main()
  25. {
  26. string ans = "";
  27.  
  28. bool was = false;
  29. int countOf10 = 0;
  30.  
  31. while (true) {
  32. string s;
  33. getline(cin, s);
  34.  
  35. if (!was)
  36. ans += s + "\n";
  37. else {
  38. string tmpAns = "";
  39.  
  40. while (true) {
  41. string tmp;
  42. getline(cin, tmp);
  43.  
  44. tmpAns += tmp + "\n";
  45.  
  46. if (tmp == "</tr>")
  47. break;
  48. }
  49. int klass = atoi(tmpAns.substr(tmpAns.find(',') + 2, 2).c_str());
  50.  
  51. if (klass == 10) {
  52. ++countOf10;
  53. int pos = tmpAns.find("rankl") + 7;
  54. int place = atoi(tmpAns.substr(pos, 3).c_str());
  55. int countDig = countDigits(place);
  56.  
  57. tmpAns.replace(pos, countDig, itos(countOf10));
  58. ans += tmpAns;
  59. }
  60. }
  61.  
  62. if (s == "</html>")
  63. break;
  64.  
  65. if (s == "<tbody>")
  66. was = true;
  67. if (s == "</tbody>")
  68. was = false;
  69. }
  70.  
  71. cout << ans;
  72.  
  73. return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement