Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- using namespace std;
- int countDigits(int num) {
- int ans = 0;
- while (num > 0) {
- ++ans;
- num /= 10;
- }
- return ans;
- }
- string itos(int num) {
- string ans = "";
- while (num > 0) {
- int digit = num % 10;
- ans += (digit + '0');
- num /= 10;
- }
- return ans;
- }
- int main()
- {
- string ans = "";
- bool was = false;
- int countOf10 = 0;
- while (true) {
- string s;
- getline(cin, s);
- if (!was)
- ans += s + "\n";
- else {
- string tmpAns = "";
- while (true) {
- string tmp;
- getline(cin, tmp);
- tmpAns += tmp + "\n";
- if (tmp == "</tr>")
- break;
- }
- int klass = atoi(tmpAns.substr(tmpAns.find(',') + 2, 2).c_str());
- if (klass == 10) {
- ++countOf10;
- int pos = tmpAns.find("rankl") + 7;
- int place = atoi(tmpAns.substr(pos, 3).c_str());
- int countDig = countDigits(place);
- tmpAns.replace(pos, countDig, itos(countOf10));
- ans += tmpAns;
- }
- }
- if (s == "</html>")
- break;
- if (s == "<tbody>")
- was = true;
- if (s == "</tbody>")
- was = false;
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement