统计成绩分数段

vector<unsigned>score(11, 0);//初始化容器 11个0
	unsigned grade;
	while (cin >> grade)
	{
    
    
		if (grade<=100)
		{
    
    
			++score[grade / 10];//统计分数段
		}
	}
	for (vector<unsigned>::iterator it = score.begin(); it != score.end(); it++)//利用迭代器输出
	{
    
    
		cout << *it << endl;
	}

猜你喜欢

转载自blog.csdn.net/weixin_47414687/article/details/115282349