Java 代码
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
int r = cin.nextInt();
int c = cin.nextInt();
int n = 0;
for (int i = 0; i < r; i++)
{
for (int j = 0; j < c; j++)
{
n += 1;
if (j == c - 1)
System.out.println ("PUM");
else
System.out.print(n + " ");
}
}
}
}