Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
591 B
1
Indexable
Never
#include <iostream>
#include <string>

using namespace std;

int main(){
    freopen("testing.inp","r",stdin);
    freopen("testing.out","w",stdout);
    string s;
    getline(cin, s);
    cin.ignore();
    
    int n = 0, sum = 0;
    string ans = "";
    for(int i = 0; i < s.size(); i++){
        if(s[i] >= 48 && s[i] <= 57){
            ++n;
            sum += s[i] - '0';
        }
        else if((s[i] >= 65 && s[i] <= 90) || (s[i] >= 97 && s[i] <= 122))
            ans = ans + s[i];
    }
    cout << n << endl << sum << endl << ans << endl;
    return 0;
}
Leave a Comment