Untitled

 avatar
unknown
c_cpp
a year ago
429 B
2
Indexable
#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';
    }
}

Editor is loading...
Leave a Comment