返回列表 發帖

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. }
複製代碼
本帖隱藏的內容需要回復才可以瀏覽
istak.teach2@gmail.com

返回列表