[英]How to print out the numbers that meet a condition?
我想知道如何打印出滿足i%3==0
要求的實際數字,因為目前我只知道如何打印出滿足所述要求的數字數量。 有什么建議么?
我的代碼:
public static int TAsk()
{
var count = 0;
for (var i = 1; i <= 100; i++)
{
if (i % 3 == 0)
count++;
}
//Console.WriteLine("There are {0} numbers divisible by 3 between 1 and 100.", count);
return count;
}
在執行count++
之前/之后,從if
-block 中打印i
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.