Board logo

標題: 11101_b8 [打印本頁]

作者: 李泳霖    時間: 2024-6-30 17:38     標題: 11101_b8

詢問輸出結果
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;

  4. void func(int f) {
  5.     while (f) {
  6.         f = f - 1;
  7.         int a = 4;
  8.         for (int i = 1; i <= a; i++) {
  9.             for (int j = 0; j < i; j++)
  10.                 printf("%d", i);
  11.             printf("\n");
  12.         }
  13.         for (int i = a - 1; i >= 1; i--) {
  14.             for (int j = 0; j < i; j++)
  15.                 printf("%d", i);
  16.             printf("\n");
  17.         }
  18.         if (f) printf("\n");
  19.     }
  20. }
  21. int main() {
  22.    func(2);
  23.    system("pause");
  24.    return 0;  
  25. }
複製代碼
本帖隱藏的內容需要回復才可以瀏覽





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/) Powered by Discuz! 7.2