我有一個問題,試圖使一個小的應用程序來解決Project Euler Problem #1。問題試圖解決項目歐拉#1
每當我試圖運行它,它會返回0,而不是233168.
我不一定要找一個絕對的答案,只是一些提示,我努力學習。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int x;
List<int> listOne = new List<int>();
for (x = 1; x < 1000; ++x)
{
if(x%3 == 0 || x%5 == 0)
{
listOne.Add(x);
}
Console.WriteLine(listOne.Sum());
Console.ReadLine();
}
}
}
}
@ MD.Unicorn哈哈,對不起,我不是故意重寫你的格式編輯。當你把你放進去的時候,我正在編輯中:/我會把它捲成一個新的。 – 2013-04-10 04:13:17
我對格式不好感到非常抱歉,我會記住我的下一篇文章。謝謝你的提示! – kmartmvp 2013-04-10 04:16:02
@ user2264393這並沒有那麼糟糕,我們只是將它整理爲未來的人,他們可能也會遇到問題1的問題:) – 2013-04-10 04:18:07