怎么实现以下列循环?2986.42
2990
3000
3010
已知:2986.42,没隔10增加一个数字。

解决方案 »

  1.   


    using System;public class Test
    {
        public static void Main()
        {
            double d = 2986.42;
            int count = 10;
            int x = ((int)(d / 10)) * 10;
            for (int i = 0; i < count; i++)
            {
                Console.WriteLine(x + i * 10);
            }
            Console.ReadKey();
        }
    }
      

  2.   


    using System;public class Test
    {
        public static void Main()
        {
            double d = 2986.42;
            int count = 10;
            int x = ((int)(d / 10)) * 10;
            for (int i = 0; i < count; i++)
            {
                Console.WriteLine(x + i * 10);
            }
            Console.ReadKey();
        }
    }
      

  3.   

    最大增加到多少?
    x=2986.42
    for(i=0 to 10)
    {
      if (round(x,0)+i) mod 10 = 0   //大意是取整后是10的倍数 取余操作
        {x=round(x,0)+i}//取到2990
    }
    tmp = x;
    for(i=tmp  to 最大数)
    {
      i=i+10
      x=i;
    }
    //上面算伪代码吧呵呵
    语法自己搞定
      

  4.   

    1.首先将2986.42转为2990,double d = 2986.42;
    int default = ((int)(d / 10)) * 10; //default = 2990
    2.循环,每次default的值加10,你懂的.