Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int n, x, i, j;
- int value,count = 0, starting;
- int matrix[500][500];
- scanf("%d%d", &n, &x);
- for(i = 0; i < n; i++)
- {
- /// i indicates row and j indicates column
- starting = i + 1;
- /* as i will start at zero, but we want to start at 1,
- so we add additional 1 with the value of i*/
- /*first element of first row is, starting = 1(i = 0 + 1) and following
- elements will increment according the first element of the column*/
- value = starting;
- if(value == x)
- {
- count++;
- }
- //this count is done in case first element of the row match with the value of x;
- for(j = 0; j < n; j++)
- {
- matrix[i][j] = value;
- value = value + starting;
- /// value will increase by the value + starting, starting indicates the increment
- if(value == x)
- {
- count++;
- }
- }
- value = 0;
- }
- printf("%d", count);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement