#include <stdio.h> void main() { int i =1,a = 2, b= 0, n = 0; for (int j = 0;i+b<=21;j++) { n = i; printf("%-3d",n); for (int k = 0;n+a+k<=21;k++) { n =n+a+k; printf("%-3d",n); } printf("\n"); b++; i = i+b; a++; } }
时间: 2024-10-07 16:23:20
#include <stdio.h> void main() { int i =1,a = 2, b= 0, n = 0; for (int j = 0;i+b<=21;j++) { n = i; printf("%-3d",n); for (int k = 0;n+a+k<=21;k++) { n =n+a+k; printf("%-3d",n); } printf("\n"); b++; i = i+b; a++; } }