#29583: C++ 紀錄


e3524167 (Kenlogin)

學校 : 不指定學校
編號 : 186743
來源 : [182.233.207.92]
最後登入時間 :
2022-03-17 21:12:56
a058. MOD3 | From: [182.233.207.92] | 發表日期 : 2022-03-13 01:23

#include <iostream>

#include <string> 

#include <sstream>

using namespace std;

int main()

{

int x = 0;

while (cin >> x)

{

int y;

int count1 = 0,count2=0,count3=0;

string a;

stringstream temp;

for (int i = 0; i < x; i++)

{

cin >> y;

a = a + to_string(y);

}

for (int i = 0; i < a.length(); i++)

{

int num;

temp << a[i];

temp >> num;

 

if (num % 3 == 0)

{

count1 = count1 + 1;

}

else if (num % 3 == 1)

{

count2 = count2 + 1;

}

else if (num % 3 == 2)

{

count3 = count3 + 1;

}

temp.str("");

temp.clear();

}

cout << count1 << " " << count2 << " " << count3 << endl;

}

}

 
ZeroJudge Forum