Untitled

mail@pastecode.io avatar
unknown
c_cpp
13 days ago
429 B
0
Indexable
Never
#include <iostream>
#include <string>
#include <vector>


void foo(std::string n,int count[]) {
    
    for (int i = 0; i < n.length(); i++) {
        count[int(n[i]) - 97] += 1;
    }
    
}

int main()
{
    std::string n;
    std::cin >> n;
    int count[122 - 96]{};
    foo(n, count);
    for (int i = 0; i < 122 - 96; i++) {
        std::cout << char(i + 97) << " : " << count[i] << '\n';
    }
}

Leave a Comment