標題:
2025/03/06 課堂重點(子夫)
[打印本頁]
作者:
李知易
時間:
2025-3-6 13:53
標題:
2025/03/06 課堂重點(子夫)
本帖最後由 李知易 於 2025-3-6 20:06 編輯
今日上課重點
(6:00 - 8:00)
:
複習
101-710
題目
今日考試:
201 - 210
隨機 1 題
(210)
(V)
301 - 310
隨機 1 題
(310)
(V)
601 - 610
隨機 1 題
701 - 710
隨機 1 題
(703)
(V)
下次考試:
201 - 210
隨機 1 題
301 - 310
隨機 1 題
601 - 610
隨機 1 題
701 - 710
隨機 1 題
今日作業:
a051: 骰子點數
遞迴解
作者:
王子夫
時間:
2025-3-6 18:38
#include<bits/stdc++.h>
#include<string>
using namespace std;
int compute(int n){
int sum=0,s,z[10]={0};
string d;
for (int i=0;i<n;i++){
s = 0;
d = to_string(i);
for (int j=0;j<d.size();j++){
z[j] = stoi(d[i]);
}
for (int j=0;j<d.size();j++){
s += pow(z[j],i.size())
}
if (s==d){
cout << s << endl;
sum += s;
}
}
return sum;
}
int main(){
int n;
cin >> n;
cout << compute(n) << endl;
return 0;
}
複製代碼
作者:
王子夫
時間:
2025-3-6 19:13
#include<bits/stdc++.h>
using namespace std;
int k(int n){
if(n==1){
return 1;
}
return n*n+k(n-1);
}
int main(){
int n;
while(cin >> n && n){
cout << k(n) << endl;
}
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2