迴圈
初始化
輸入數字
判別餘數
輸出
#include <iostream>
using namespace std;
int main()
{
int num;
int input;
int remainder[3];
while(cin >> num)
{
remainder[0] = remainder[1] = remainder[2] = 0;
for(int i = 1; i <= num; i++)
{
cin >> input;
remainder[input%3]++;
}
cout << remainder[0] << " " << remainder[1] << " " << remainder[2] << endl;
}
return 0;
}
全站熱搜
留言列表