你是在c ++上编程,你应该使用c ++方式.
#includeint main () { std::string textline; std::getline (std::cin,textline); for(char ch = 'a'; ch <= 'z'; ch++) { std::size_t n = std::count(textline.begin(), textline.end(), ch); if(n > 0) std::cout << " - " << n << "," << std::endl; } }