标签:style blog color ar sp for div on log
using System; public class ForEachTest { public static void Main() { int odd=0; int eve=0; int length=100; int[] arr=new int[length]; Random r = new Random(); for(int i=0;i<length;i++) //随机数赋值 { arr[i]= r.Next(); } foreach(int tem in arr) //foreach 举例 { if(tem%2==0) eve++; else odd++; } Console.WriteLine("奇数"+odd+"个"); Console.WriteLine("偶数"+eve+"个"); } }
标签:style blog color ar sp for div on log
原文地址:http://www.cnblogs.com/quke123/p/4101809.html