[英]How to print out the numbers that meet a condition?
I was wondering how to print out the actual numbers that meet the requirement of i%3==0
, cause currently I only know how to print out the amount of numbers that meet said requirement.我想知道如何打印出满足
i%3==0
要求的实际数字,因为目前我只知道如何打印出满足所述要求的数字数量。 Any suggestions?有什么建议么?
My code:我的代码:
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;
}
Before/after doing count++
, print i
from that if
-block.在执行
count++
之前/之后,从if
-block 中打印i
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.