Board logo

標題: 11101_b17易 [打印本頁]

作者: 李泳霖    時間: 2024-6-30 17:43     標題: 11101_b17易

問下列程式碼輸出什麼?
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. char s[] = {'a', 'b', 'a', 'b', 'a', 'a'};
  5. void f(char x) {
  6.     for (int i = 0; i < 7; i++) {
  7.         if (s[i]=='c')
  8.            s[i] = s[i+1] ;
  9.         else s[i] = x;
  10.     }
  11. }
  12. int main() {
  13.     f('a');
  14.     for (int i = 0; i < 7; i++)
  15.         printf("%c", s[i]);

  16.     system("pause");
  17.     return 0;  
  18. }
複製代碼
本帖隱藏的內容需要回復才可以瀏覽





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