The input for this program consists of numbers n, a0, a1, ..., a{n-1}, b0, b1, b{n-1}. In this, ai and bi are supposed to be the ith least significant digits of numbers A, B. You are supposed to print the digits of the sum of A, B, again from least significant to the most significant - one per line. Note that the sum can have n+1 digits, and so you should print n+1 digits, with the most significant digit being possibly 0.You may assume that the size of an array can be a value that is known only during execution. For example, it is OK to write
"int n; cin >>n; int A[n];" program in c++
Answers
Answered by
0
Answer:
JAVA SCRIPT IS CORRECT ANSWER.........
I HOPE HELP YOU..............
OKKKKKKKKKK........
THANKS.....
Answered by
0
Answer:
using namespace std;
int main()
{
int sum = 0, rem = 0, t =0;
int a[50][50];
int n, m=2;
cin>> n;
for(int i = 0; i< m; i++)
{
for(int j = 0; j < n; j++)
{
cin>>a[i][j];
}
}
for(int i = 0; i<m; i++)
{
for(int j = 0; j< n; j++)
{
if(t < n)
{
t= t+1;
sum = rem + (a[i][j] + a[i+1][j]);
rem = sum/10;
sum = sum%10;
cout << sum << std::endl;
}
}
}
cout<< rem << endl;
}
Explanation:
Similar questions