2009-05-01

Input :

  • 請輸入一個數字: 3

Output :

  • 1
  • 2
  • 3
  • 1 2
  • 2 3
  • 1 2 3

##ReadMore##

Source Code :

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main() {
  4.     int num;
  5.     printf("請輸入一個數字: ");
  6.     scanf("%d", &num);
  7.     for(int a = 1; a <= num; a++) {
  8.         int x = 1;
  9.         int y = a;
  10.         for(int l = y; l <= num; l++) {
  11.             for(int f = x; f <= l; f++) {
  12.                 printf("%d ", f);
  13.             }
  14.             x += 1;
  15.             printf("\n");
  16.         }
  17.     }
  18.     system("PAUSE");
  19.     return 0;
  20. }

0 回應:

張貼留言