forked from TECHOUS/DSKaKhel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRowColSum.cpp
More file actions
47 lines (44 loc) · 687 Bytes
/
RowColSum.cpp
File metadata and controls
47 lines (44 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<stdio.h>
#include<malloc.h>
int main()
{
int testcases;
scanf("%d\n",&testcases );
while(testcases--)
{
int N,W;
int X;
char R;
scanf("%d %d",&N,&W );
scanf("%d %c",&X,&R);
int i , j, k;
int arr[100][100]={0};
int sum = 0;
k = 1;
for(i = 0 ; k <=N ; i++)
{
for(j = 0 ; j < W && k <= N ; j++ )
{
arr[i][j] = k;
k = k+1;
}
}
k = i;
if(R == 'C')
{
for(i = 0 ; i <= k ; i++)
{
sum += arr[i][X-1];
}
}
else
{
for(i = 0 ; i < W ; i++)
{
sum = sum + arr[X-1][i];
}
}
printf("%d\n",sum );
}
return 0;
}