Created
July 4, 2018 07:45
-
-
Save Nazmul56/5dfe0b76248559651ad4bf09cff76216 to your computer and use it in GitHub Desktop.
Sum Of Row and Column
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdio.h> | |
using namespace std; | |
int main() | |
{ | |
int R; int C; | |
int inputArray[100][100] = {0};; | |
int tc; | |
scanf("%d %d ", &R, &C); | |
for(int row =0; row < R; row++){ | |
for(int cloumn = 0; cloumn < C; cloumn ++){ | |
int input; | |
scanf(" %d", &input); | |
inputArray[row][cloumn] = input; | |
} | |
} | |
for(int row =0; row <=R; row++){ | |
int rowSum =0; | |
int cloumnSum =0; | |
for(int cloumn = 0; cloumn <= C; cloumn ++){ | |
int value = inputArray[row][cloumn]; | |
rowSum = rowSum + value; | |
if(row == R){ | |
} else { | |
inputArray[R][cloumn] = inputArray[R][cloumn]+ inputArray[row][cloumn]; | |
} | |
if(cloumn == C){ | |
} else{ | |
inputArray[row][C] = rowSum; | |
} | |
printf("%d ", inputArray[row][cloumn]); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment