Онлайн компилятор C

#include <stdio.h> int main() { int n,m,num=1,i=1; scanf("%d%d",&n,&m); while(i<=n){ int j=1; while(j<=m){ printf("%d ",num*i); num++; j++; } printf("\n"); i++; } return 0; }
This code reads two integers n and m, then prints a grid of n rows and m columns. Each cell contains a number that is the product of the current row number and a counter that increases by 1 across all cells. The counter `num` starts at 1 and increments with every printed number, so the values are 1*1, 2*1, 3*1, ... in the first row, then 1*2, 2*2, ... in the second row, and so on.

- The variable `num` is incremented inside the inner loop, but it is never reset for each new row. This means the multiplication `num*i` uses a counter that keeps growing across rows, which likely does not match the intended pattern of a multiplication table or a simple grid.
- Consider what value you want to multiply by `i` in each column. If you want each row to start with the same sequence (like 1, 2, 3, ...), then `num` should be reset to 1 at the beginning of each row, or you should use `j` directly instead of `num`.