编辑代码

public class test{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String result = "";

        for(int i=1;i<=n;i++){
            for (int j = 1; j <= i; j++) {
                result += i + " ";
            }
            result += "\n";
        }

        System.out.println(result);
    }
}