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:38

#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
    int A[3][2];
    int B[3][2];
    int C[3][2];
    for (int i = 0; i < 3; i++)
    {
        int count = 0;
        int value = 0;
        string input;
        getline(cin,input);
        stringstream ss(input);
        while (ss >> value) // reads numbers from the setted up ss one at a time into value
        {
            count++;
            if (count > 2)
            {
                cout << "Wrong format, please make sure there are exactly 2 numbers on each line.";
                return 0;
            }
            A[i][count - 1] = value;
        }
        if (count < 2)
        {
            cout << "Wrong format, please make sure there are exactly 2 numbers on each line.";
            return 0;
        }
    }
    for (int i = 0; i < 3; i++)
    {
        int count = 0;
        int value = 0;
        string input;
        getline(cin,input);
        stringstream ss(input);
        while (ss >> value) // reads numbers from the setted up ss one at a time into value
        {
            count++;
            if (count > 2)
            {
                cout << "Wrong format, please make sure there are exactly 2 numbers on each line.";
                return 0;
            }
            B[i][count - 1] = value;
        }
        if (count < 2)
        {
            cout << "Wrong format, please make sure there are exactly 2 numbers on each line.";
            return 0;
        }
    }

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            C[i][j] = A[i][j] + B[i][j];
            cout << C[i][j];
            if (j != 1)
            {
                cout << " ";
            }
        }
        cout << "\n";
    }
}