Submission

Status:

---------

Subtask/Task Score:

0/100

Score: 0

User: KanemiyaKana

Problemset: บวกเลขฐาน

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-02 16:38:45

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> //for setprecision
using namespace std;

int main()
{
    double output = 0;
    int total = 0;
    int amount = 0;
    int all[20];
    for (int i = 0; i <= 10; i = i + 10)
    {
        int value = 0;
        int count = 0;
        int line[10];
        string input;
        getline(cin, input);
        stringstream ss(input);
        while (ss >> value)
        {
            count++;

            if (count > 10)
            {
                cout << "Wrong format, please make sure there are exactly 10 numbers on each line.";
                return 0;
            }

            line[count - 1] = value;
        }
        if (count < 10)
        {
            cout << "Wrong format, please make sure there are exactly 10 numbers on each line.";
            return 0;
        }
        for (int j = 0; j < 10; j++)
        {
            all[i + j] = line[j];
        }
    }
    for (int i = 0; i < 20; i++)
    {
        if (all[i] > 0)
        {
            total = total +all[i];
            amount++;
        }
    }
    if (output <= 0)
    {
        cout << "No positive numbers";
    }
    else
    {
        output = total/amount;
        cout << fixed << setprecision(2) << output;
    }
}