1 / 7

数组的基本操作

数组的基本操作. 数组的输入、输出 数组元素的查找 数组元素的移动 数组元素的插入 数组元素的删除 排序. 题目: 1117-1123. 1121: 【 入门 】 数组元素的插入. A[1]. A[2]. A[3]. A[4]. A[5]. A[6]. 7. 2. 3. 4. 5. 5-->6 4-->5 3-->4 2-->3. 9. 第 2 个位置上. 如何移动的问题. 1121: 【 入门 】 数组元素的插入. A[1]. A[2]. A[3]. A[4]. A[5]. A[6]. 7. 2. 3. 4.

Télécharger la présentation

数组的基本操作

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 数组的基本操作 • 数组的输入、输出 • 数组元素的查找 • 数组元素的移动 • 数组元素的插入 • 数组元素的删除 • 排序 题目:1117-1123

  2. 1121: 【入门】数组元素的插入 A[1] A[2] A[3] A[4] A[5] A[6] 7 2 3 4 5 5-->6 4-->5 3-->4 2-->3 9 第2个位置上 如何移动的问题

  3. 1121: 【入门】数组元素的插入 A[1] A[2] A[3] A[4] A[5] A[6] 7 2 3 4 5 n-1 x 5 6 4 5 3 4 2 3 for i:=5 downto 2 do a[i+1] := a[i] n X+1 for i:=6 downto 3 do a[i] := a[i-1]

  4. 1121: 【入门】数组元素的插入 题目描述 在一个数组的第x个位置插入一个新的数y 输入:有四行 第一行有一个整数n ( 5 <= n <= 10)第二行有n个整数 第三行有一个整数x,为要插入的位置 第四行有一个整数y,为要插入的整数 输出:更新后的数组 样例输入 5 7 2 3 4 5 2 9 样例输出 7 9 2 3 4 5 ---n ---a[ ] ---x ---y

  5. 题1119:【入门】元素插入有序数组 Input 第一行一个整数n :等待插入的数 第二行一个整数m :数列中数的个数 第三行m个整数(空格隔开) Output 一行整数:新的数列(空格隔开) Sample Input 2 4 1 3 4 5 Sample Output 1 2 3 4 5 插入的位置要找 w

  6. 找错 李思婉 var m,n,i,t:longint; x:array[1..100] of longint; begin readln(n); readln(m); for i:=1 to m do read(x[i]); for i:=1 to m do if n<x[i] then begin t:=i;break;end; for i:=1 to t-1 do write(x[i],' '); write(n); for i:=t to m do write(' ',x[i]); end. 14 3 10 11 12

  7. var m,n,i,w:longint; x:array[1..100] of longint; begin readln(n); readln(m); for i:=1 to m do read(x[i]); w:=1; while (n>x[w]) and (w<=m) do inc(w); for i:=m downto w do x[i+1]:=x[i]; x[w]:=n; for i:=1 to m do write(x[i],' '); write(x[m+1]); end.

More Related