using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Collections;namespace _5_3{? ? class Program? ? {? ? ? ? static void Main(string[] args)? ? ? ? {? ? ? ? ? ? ArrayList a = new ArrayList(10);? ? ? ? ? ? a.Add(89);? ? ? ? ? ? a.Add(78);? ? ? ? ? ? a.Add(91);? ? ? ? ? ? a.Add(92);? ? ? ? ? ? a.Add(72);? ? ? ? ? ? a.Add(69);? ? ? ? ? ? a.Add(46);? ? ? ? ? ? a.Add(67);? ? ? ? ? ? a.Add(92);? ? ? ? ? ? a.Add(84);? ? ? ? ? ? Console.Write("修改前的元素");? ? ? ? ? ? for (int i = 0; i < a.Count; i++)? ? ? ? ? ? {? ? ? ? ? ? ? ? Console.Write("{0} ", a[i]);? ? ? ? ? ? }? ? ? ? ? ? Console.WriteLine();? ? ? ? ? ? int sum=0;? ? ? ? ? ? foreach (int x in a)? ? ? ? ? ? {? ? ? ? ? ? ? ? sum = sum + x;? ? ? ? ? ? }? ? ? ? ? ? a.Add(sum);? ? ? ? ? ? foreach (int x in a)? ? ? ? ? ? {? ? ? ? ? ? ? ? if (x < 60) a.Remove(x);? ? ? ? ? ? }? ? ? ? ? ? Console.Write("修改后的元素");? ? ? ? ? ? for (int i = 0; i < a.Count; i++)? ? ? ? ? ? {? ? ? ? ? ? ? ? Console.Write("{0} ", a[i]);? ? ? ? ? ? }? ? ? ? }? ? }}
- 1 回答
- 0 關(guān)注
- 1309 瀏覽
添加回答
舉報
0/150
提交
取消