標題:
040 一維陣列宣告
[打印本頁]
作者:
游東祥
時間:
2014-4-19 13:01
標題:
040 一維陣列宣告
學會使用一維陣列:
宣告方式
宣告後直接指定陣列內容
修改陣列內容
讀取陣列內容
作者:
林宇翔
時間:
2014-4-19 13:54
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int z[10] = {20, 0, 30, 0, 40, 0, 50, 0, 60, 0};
z[1] = z[0] - 5;
z[3] = z[2] - 5;
z[5] = z[4] - 5;
z[7] = z[6] - 5;
z[9] = z[8] - 5;
cout << z[0] << " " << z[1] << " " << z[2] << " " << z[3] << " " << z[4] << " ";
cout << z[5] << " " << z[6] << " " << z[7] << " " << z[8] << " " << z[9] << endl;
cout << endl;
system ("pause");
return 0;
}
複製代碼
作者:
李允軒
時間:
2014-4-19 13:58
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int z[10] = {20,0,30,0,40,0,50,0,60,0};
z[1] = z[0] -5
z[3] = z[2] -5
z[5] = z[4] -5
z[7] = z[6] -5
z[9] = z[8] -5
cout << z[0] << " " << z[1] << " " << z[2] << " " << z[3] << " " << z[0] << " ";
cout << z[4] << " " << z[5] << " " << z[6] << " " << z[7] << " " << z[8] << " " << z[9] << " "
system ("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2