Код: Выделить всё
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <fstream>
using namespace std;
int main()
{
setlocale (LC_ALL, "RUS");
string s;
ifstream v; //открываем фаил для чтения
v.open ("D:\\trr.txt");
v >> s;
map <char, int> m; //использую ассоциативный массив
for (int i=0; i<s.length(); i++) //записываю символы из строки
{
char c=s[i];
m[c]++;
}
map <char, int>::iterator itr; //итератор
for (itr=m.begin(); itr!=m.end(); itr++) //вывод от начала до конца по алфавиту
{
cout << itr->first << ":" << itr->second << endl;
}
}