標題:
a111. 12149 - Feynman
[打印本頁]
作者:
李知易
時間:
6 天前 11:25
標題:
a111. 12149 - Feynman
題目連結
作者:
張駿霖
時間:
6 天前 11:43
#include<bits/stdc++.h>
using namespace std;
int f(int n){
if(n==1)
return 1;
rerurn n*n+f(n-1);
}
int main(){
cint n;
while(cin>>n)
return 0;
cout<<f(n)<<endl;
return 0;
}
複製代碼
作者:
洪承廷
時間:
6 天前 12:15
#include<bits/stdc++.h>
using namespace std;
int f(int a)
{
if(a!=1)
return f(a-1)+pow(a,2);
else
return 1;
}
int main()
{
int a;
while(cin>>a)
{
if(a==0)
return 0;
else
cout<<f(a)<<endl;
}
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2