Board logo

標題: 040 一維陣列宣告 [打印本頁]

作者: 游東祥    時間: 2014-4-19 13:01     標題: 040 一維陣列宣告

學會使用一維陣列:
作者: 林宇翔    時間: 2014-4-19 13:54

  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         int z[10] = {20, 0, 30, 0, 40, 0, 50, 0, 60, 0};
  7.                 z[1] = z[0] - 5;
  8.                 z[3] = z[2] - 5;
  9.                 z[5] = z[4] - 5;
  10.                 z[7] = z[6] - 5;
  11.                 z[9] = z[8] - 5;
  12.         cout << z[0] << " " << z[1] << " " << z[2] << " " << z[3] << " " << z[4] << " ";
  13.                 cout << z[5] << " " << z[6] << " " << z[7] << " " << z[8] << " " << z[9] << endl;
  14.         cout << endl;
  15.         system ("pause");
  16.         return 0;
  17. }
複製代碼

作者: 李允軒    時間: 2014-4-19 13:58

  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         int z[10] = {20,0,30,0,40,0,50,0,60,0};
  7.         z[1] = z[0] -5
  8.         z[3] = z[2] -5
  9.         z[5] = z[4] -5
  10.         z[7] = z[6] -5
  11.         z[9] = z[8] -5
  12.         cout << z[0] << " " << z[1] << " " << z[2] << " " << z[3] << " " <<  z[0] << " ";
  13.         cout << z[4] << " " << z[5] << " " << z[6] << " " << z[7] << " " <<  z[8] << " " << z[9] << " "
  14.         system ("pause");
  15.         return 0;
  16. }
複製代碼





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