Preview:
#include <iostream>

using namespace std;

int dvejetai(int x) {
    int count = 0;

    while (x > 0) {
        if (x % 10 == 2) {
            count++;
        }
        x /= 10;
    }

    return count;
}

int main() {
    int x;
    cout << "Įveskite dviženklį teigiamą skaičių: ";
    cin >> x;

 if (x < 10 || x > 99) {
        cout << "Įvestas skaičius nėra dviženklis." << endl;
        return 1;
    }

    int totalSum = 0;

    for (int i = 0; i < x; ++i) {
        if (i % 2 == 0) {
            totalSum += dvejetai(i);
        }
    }

    cout << "Sunaudojo dvejetų skaičiui parašyti " << x << " yra: " << totalSum <<" dvejetai." <<endl;

    return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter