using System; using System.Collections.Generic; using System.Text;
namespace test { class Program { static void Main(string[] args) { int[] num={1,2,4,6,8,4,5,6}; int count=0; foreach(int x in num){ if(x==4) { count+=1; Console.Write(x+" "); } } Console.WriteLine(count); } } }
输出:4 4 2