如题,初学者求教啊。知道的希望可以麻烦下写出来。
我自己无论怎么写都无法调试成功啊。
谢谢了。

解决方案 »

  1.   

    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();
            }
        }
    }
      

  2.   

    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);
      

  3.   

    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);