C#程序:计算输入数字中1的个数

C#程序:计算输入数字中1的个数

int[] num = new int[] {1, 25, 1, 55, 1};

Now loop through and find for 1, if 1 is there, 6 then increment the variable that counts the occurrence −

foreach(int j in num) { if (j == 1) { cal++; } }登录后复制