为什么怎么改都是编译失败?

P1035 [NOIP2002 普及组] 级数求和

huanhuan5555 @ 2024-11-07 16:51:43

namespace ConsoleApp7

{

internal class Program
{
    static void Main(string[] args)
    {

        double Sn = 0;
        double n=0;
        n = GetSn(1);
        Console.WriteLine(n);

       int  GetSn(int x)
        {
            int i = 1;

                for (i = 1; i < 100000; i++)
                {
                    Sn = Sn +(double) 1.0 / i;
                if (Sn > x)

                    break;

                }
            return i;
            }

    }
}

}


by PVYCVJ @ 2024-11-10 16:36:19

@huanhuan5555 兄啊,从头到尾读一遍题目吧,如果还不理解就从P1001练起


by huanhuan5555 @ 2024-11-11 16:51:08

@PVYCVJ 我现在加了一个k的输入,然后直接0分


上一页 |