跳轉到內容

C++ 程式設計/範圍/示例/複雜範圍計劃 2

來自維客書,開放的世界開放的書籍
// Complicated Scope Program, variation 2
#include <iostream>
  
using namespace std; /* outermost level of scope starts here */

int i;

int main(){              /* next level of scope starts here */
  int i;
  i = 5;

  for(               /* next level of scope starts here */
      int i = 1;
      i<10 && cout << i << ' ';
      ++i )  
  {                  /* next level of scope starts here */
    int i = -1;
    cout << i << ' ';
  }                  /* two levels of scope end here*/

  cout << i << endl;
  return 0;
}                    /* next and outermost levels of scope end here */
華夏公益教科書