#13269: 請問這樣寫是錯在哪裡?


eechiu (eechiu)


#include<iostream>
using namespace std;
int main()
{
int d,ans,count1,a;
while(cin>>d)
{
count1=1;
a=1;//第一項
ans=1;
for(int i=d;count1<=49;i=i+d)
{
a+=i;//算出各項
ans+=a;//加總各項

count1+=1;
}

cout<<ans<<endl;

}
return 0;
}

 

#13276: Re:請問這樣寫是錯在哪裡?


anandrewboy70900 (ShowTsai)


for(int i=1;count1<=49;i=i+d)

 
#13286: Re:請問這樣寫是錯在哪裡?


eechiu (eechiu)


for(int i=1;count1<=49;i=i+d)

 



過了 感謝樓上