Input :
- 請輸入一個數字: 3
Output :
- 1
- 2
- 3
- 1 2
- 2 3
- 1 2 3
##ReadMore##
Source Code :
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- int num;
- printf("請輸入一個數字: ");
- scanf("%d", &num);
- for(int a = 1; a <= num; a++) {
- int x = 1;
- int y = a;
- for(int l = y; l <= num; l++) {
- for(int f = x; f <= l; f++) {
- printf("%d ", f);
- }
- x += 1;
- printf("\n");
- }
- }
- system("PAUSE");
- return 0;
- }
0 回應:
張貼留言