Start: May, 31, 2017 13:30:00
2017ACM通识课期末考试
End: May, 31, 2017 17:30:00
Time elapsed:
Time remaining:

Problem_ID: I
Result: Accepted
Time: 5ms
Memory: 1092kB
Author: wqd12138
In contest: 1090

#include<stdio.h>
int main(void) {
	int n, i, j, k=1, l=1;
	while(scanf("%d", &n)!=EOF) {
		for(i=1;i<=n;i++) {
			if(i!=n) {
			k=l;
			k=k+i-1;
			l=k;
			for(j=1;j<=n-i+1;j++) {
				if(j==1)
					printf("%d ", k);
				else {
					k=k+i+j-1;
				    if(j!=n-i+1)
					    printf("%d ", k);
				    else
					    printf("%d\n", k);
				}
			}
			}
			else {
				k=l;
			k=k+i-1;
			l=k;
			for(j=1;j<=n-i+1;j++) {
				if(j==1)
					printf("%d ", k);
				else {
					k=k+i+j-1;
				    if(j!=n-i+1)
					    printf("%d ", k);
				    else
					    printf("%d", k);
				}
			}
			}
		}
	}
	return 0;
}