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:54
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
using namespace std;
int main()
{
int all[5][3];
for (int i = 0; i < 5; i++)
{
int value = 0;
int count = 0;
int line[3];
string input;
getline(cin, input);
stringstream ss(input);
while(ss >> value)
{
count++;
if (count > 3)
{
cout << "Wrong format, please make sure there are exactly 3 numbers on each line.";
return 0;
}
line[count - 1] = value;
}
if (count < 3)
{
cout << "Wrong format, please make sure there are exactly 3 numbers on each line.";
return 0;
}
for (int j = 0; j < 3; j++)
{
all[i][j] = line[j];
}
}
for (int i = 0; i < 5; i++)
{
int row = 0;
for (int j = 0; j < 3; j++)
{
row = row + all[i][j];
}
cout << row << " ";
}
cout << "\n";
for (int i = 0; i < 3; i++)
{
int column = 0;
for (int j = 0; j < 5; j++)
{
column = column + all[j][i];
}
cout << column << " ";
}
}