第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么小于60的數(shù)運行時會出錯

為什么小于60的數(shù)運行時會出錯

C#
三色堇忞 2016-04-16 10:02:08
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 回答

已采納
?
一只大卡車

TA貢獻15條經(jīng)驗 獲得超8個贊

foreach遍歷要求ArrayList大小不發(fā)生改變,否則拋出異常,換for循環(huán)即可

http://img1.sycdn.imooc.com//5711aee70001e82b13500519.jpg

查看完整回答
3 反對 回復 2016-04-16
  • 1 回答
  • 0 關(guān)注
  • 1309 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號