------解决方案-------------------- using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _01求助
{
class Program
{
static void Main(string[] args)
{
int k=0;
for (int i = 1; i <= 100; i++)
{
if (i % 3 == 0 && i % 5 != 0)
{
Console.WriteLine(i);
k++;
}
}
Console.WriteLine("能被3整除不能被5整除的数一共有{0}个", k);
Console.ReadKey();
}
}
}
------解决方案--------------------
var result = (from n in Enumerable.Range(1, 100)
where n % 3 == 0 && n % 5 != 0
select n)
.ToList();
result.ForEach(x=>{ Console.Write("{0} ", x);});
Console.WriteLine("\r\n总共{0}个数。",result.Count);
------解决方案--------------------
var result = (from n in Enumerable.Range(1, 100)
where n % 3 == 0 && n % 5 != 0
select n)
.ToList();
result.ForEach(x=>{ Console.Write("{0} ", x);});
Console.WriteLine("\r\n总共{0}个数。",result.Count);