Untitled
unknown
c_cpp
2 years ago
429 B
5
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