buptoj 1512
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
string num;
num.clear();
cin >> num;
string::iterator iter; /* how to using string iterator */
int nine = 0, one = 0, two = 0;
for (iter=num.begin() ; iter!=num.end() ; iter++)
{
if (*iter == '9')
{
nine++;
}
else if (*iter == '1')
{
one++;
}
else if (*iter == '2')
{
two++;
}
}
cout << nine << endl;
cout << one << endl;
cout << two << endl;
}
阅读(1042) | 评论(0) | 转发(0) |