指定数量的数据输入综合题,要求用while循环结合con导入。具体如下!

img

img

输入n个数,将符合以下至少两个条件的数进行输出、计数并求和。
1.是一个三位数
2.个位+十位刚好等于5
3.能够被3整除

#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, i = 0, count = 0, sum = 0;
    cin >> n;
    while (i < n)
    {
        cin >> x;
        i++;
        int c = 0;
        if (x >= 100 && x <= 999)
            c++;
        if (x % 10 + x / 10 % 10 == 5)
            c++;
        if (x % 3 == 0)
            c++;
        if (c >= 2)
        {
            count++;
            sum += x;
            cout << x << ' ';
        }
    }
    if (count == 0)
        cout << "no";
    else
        cout << '\n' << count << ' ' << sum;
}