freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

[工學]第3章c程序設計_循環(huán)(編輯修改稿)

2024-11-15 00:19 本頁面
 

【文章內(nèi)容簡介】 [2]。 //由 2個整數(shù)組成的數(shù)組 每個元素都是一個一維整數(shù)數(shù)組。 數(shù)組 格式 2: 交錯數(shù)組名 [ i]=new 類型 []{值 1,…, 值 n}。 如: ja[0] = new int[] { 1, 3, 5, 7, 9 }。 //由 5個整數(shù)組成的數(shù)組 ja[1] = new int[] { 0, 2, 4, 6 }。 //由 4個整數(shù)組成的數(shù)組 ja[2] = new int[] { 11, 22 }。 //由 2個整數(shù)組成的數(shù)組 數(shù)組 格式 3: 定義 交錯 數(shù)組時初始化 類型 [ ][ ] 交錯數(shù)組名 =new 類型 [ ][ ] {元素初始化列表 }; 如: int[ ][ ] ja = new int[ ][ ] { new int[] {1,3,5,7,9}, new int[] {0,2,4,6}, new int[] {11,22} }。 數(shù)組 格式 4:格式 3的簡化格式 類型 [ ][ ] 交錯數(shù)組名 ={元素初始化列表 }; 如: int[ ][ ] aj = { new int[] {1,3,5,7,9}, new int[] {0,2,4,6}, new int[] {11,22} }; 數(shù)組 3.交錯數(shù)組元素的引用 交錯數(shù)組名 [交錯數(shù)組下標 ][元素數(shù)組下標 ] 如: ja[0][1] = 33。 // 把 33賦值給 ja[0]數(shù)組的第 1個元素 ja[2][2] = 44。 // 把 44賦值給 ja[2]數(shù)組的第 2個元素 數(shù)組 4. 說明 :交錯數(shù)組中元素可定義為二維數(shù)組。 如: int[][,] ja = new int[3][,] { new int[,] { {1,3}, {5,7} }, new int[,] { {0,2}, {4,6}, {8,10} }, new int[,] { {1,2,3}, {4,5,6}, {7,8,9} } }。 ja[0]為 2行 2列數(shù)組; ja[1]為 3行 2列數(shù)組 。 ja[2]為 3行 3列數(shù)組。 數(shù)組 ( ArrayList) 數(shù)組列表是一種不需定義長度,數(shù)組元素個數(shù)按需動態(tài)增加,數(shù)組元素類型為變體類型(可存放任何類型數(shù)據(jù)的類型)的數(shù)組。 1.數(shù)組列表的定義 ( 1)引用命名空間 。 由于 ArrayList屬于命名空間 ,所以使用前必須先引用該命名空間。 using 。 數(shù)組 ( 2)定義格式: AaaryList 數(shù)組列表名 =new ArrayList()。 如: ArrayList myAL = new ArrayList()。 定義名為 myAL的數(shù)組列表。 2.數(shù)組屬性(容量和長度) ( 1) Capacity屬性(容量) :設置數(shù)組列表可以存儲元素個數(shù)。 ( 2) Count屬性(長度) :返回數(shù)組列表實際元素個數(shù)。 數(shù)組 3.數(shù)組的方法 ( 1) Add方法: 數(shù)組列表名 .Add(對象 )。 將對象添加到數(shù)組列表結(jié)尾處,并返回數(shù)組下標(索引)。如: ArrayList myAL = new ArrayList()。 string s = Hello。 (s)。 int i = 123。 (i)。 (!)。 數(shù)組 ( 2) Insert方法: 數(shù)組列表名 .Insert(index,對象 )。 將對象插入到數(shù)組列表下標為 index前面。 ( 3) Remove方法: 數(shù)組列表名 .Remove(對象 )。 從數(shù)組列表中刪除對象所在的數(shù)組元素。 ( 4) RemoveAt方法: 數(shù)組列表名 .RemoveAt(index)。 從數(shù)組列表中刪除 index處的數(shù)組元素。 ( 5) Clear方法: 數(shù)組列表名 .Clear()。 刪除數(shù)組列表中所有元素。 數(shù)組 4.元素引用 數(shù)組列表名 [下標表達式 ] 注意:數(shù)組列表元素為變體類型,所以引用時必須轉(zhuǎn)換成適當?shù)念愋汀? 例 36 數(shù)組列表定義,添加、插入、刪除數(shù)組元素,顯示數(shù)組長度示例。 ( 1)新建解決方案 ( 2)窗體屬性設置 : Name:frm_myAL Text:數(shù)組列表使用示例 數(shù)組 ( 3)添加控件與設置控件屬性 表 1標簽控件的屬性設置 數(shù)組 Name Label1 Label2 Label3 Text 數(shù)組列表元素值 數(shù)組列表容量 數(shù)組實際元素個數(shù) Name txt_myAL txt_Capacity txt_Count Text 表 2 文本框控件屬性設置 表 3 命令控件屬性設置 Name btn_Add btn_Insert btn_RemoveAt Text 添加元素 插入元素 刪除指定元素 數(shù)組 圖 數(shù)組列表應用示例 ( 4)引用命名空間 using 。 ( 5)定義數(shù)組列表 myAL ArrayList myAL = new ArrayList()。 ( 6)窗體 Load事件 private void frm_myAL_Load(object sender, EventArgs e) { = ()。 = ()。 } 數(shù)組 ( 7) 添加按鈕事件處理函數(shù) private void btn_Add_Click(object sender, EventArgs e) { string s = Hello。 (s)。 int i = 123。 (i)。 (!)。 s = 。 for (i = 0。 i 3。 i++) s += (myAL[i]) + 。 = s。 = ()。 = ()。 } 數(shù)組 數(shù)組 ( 8)插入按鈕事件處理函數(shù) private void btn_Insert_Click(object sender, EventArgs e) { int n。 myAL[1] = world。 //重新賦值,原先為整數(shù) (2, Wele)。 string s = 。 n = 。 for (int i = 0。 i n。 i++) s += (myAL[i]) + 。 = s。 = ()。 = ()。 } ( 9)刪除按鈕事件處理函數(shù) private void btn_RemoveAt_Click(object sender, EventArgs e) { int n。 (2)。 string s = 。 n = 。 for (int i = 0。 i n。 i++) s += (myAL[i]) + 。 = s。 = ()。 = ()。 } 數(shù)組 對數(shù)組和數(shù)組列表使用 foreach 1. foreach語句 foreach (數(shù)據(jù)類型 變量 in 表達式 ) 語句 2. 對數(shù)組或數(shù)組列表使用 foreach int[] numbers = { 4, 5, 6, 1, 2, 3, 2, 1, 0 }。 foreach (int i in numbers) { …… } 數(shù)組 C++中類與對象的定義 類由描述某類事物的數(shù)據(jù) (數(shù)據(jù)成員 )及處理數(shù)據(jù)的函數(shù)(成員函數(shù) )組成。類的定義格式為: class 類名 { public: //定義公有數(shù)據(jù)成員或
點擊復制文檔內(nèi)容
教學課件相關推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1