陣列的用法


動手寫個陣列~真開心~哈哈哈哈哈


#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
    //宣告陣列
    int months[12];
   
    //各給陣列元素一個數值
    for(int i = 0 ;  i <= 11 ; i ++ )
    {
            months[i]= i + 1;
    }
   
    //印出陣列值
    for( int i = 0 ; i  <= 11 ; i++)
    {
         cout << "陣列第" << i << "個元素的值是" << months[i] << "月" << endl;
    }
     
    system("pause");
    return 0;
}

留言