我製作了一個程序,讀取一串隨機數的輸入,並測試它們是否符合特定條件。如果他們符合標準,那麼該方法返回true。如何在c中創建一個真正的回報計數#
我在想什麼是否有一種方法可以保持總共有多少個值返回true。
爲了節省空間生病,只是發佈輸入法和計數方法我已經開始使用!
任何幫助將不勝感激!
這是我在迄今爲止哪裏...
public bool Requirement(int input, int countOfTrue)
{
if (input % 8 == 0 && input % 11 == 0)
{
Console.WriteLine("True");
countOfTrue = countOfTrue + 1;
return true;
}
return false;
}
public int TotalTrue(int countOfTrue)
{
Console.WriteLine("Number of True: ");
return countOfTrue;
}
你不能在這種情況下使用。您必須使用ref關鍵字。 – deloreyk
@KevinDeLorey:謝謝你的發現,糾正了我的帖子。 –