2022年6月13日 星期一

g796: 檔案分類 (Files)

程式碼

#include<iostream>
using namespace std;

int main()
{
	int n, file[100] = { 0 }, index = 0;
	string s;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> s;
		index = (s[3] - '0') * 10 + (s[4] - '0');
		file[index] ++ ;
	}
	for (int i = 0; i < 100; i++)
	{
		if (file[i])
		{
			cout << i << " " << file[i] << endl;
		}
	}
	return 0;
}

沒有留言:

張貼留言