標題:
2025/5/2 課堂重點(若恩)
[打印本頁]
作者:
郭竑志
時間:
2025-5-2 20:10
標題:
2025/5/2 課堂重點(若恩)
本帖最後由 郭竑志 於 2025-5-2 21:06 編輯
[今日考試]
110 基本認識 (比大小)
203 選擇敘述與迴圈 (相對應的英文單字)
310 函式與陣列 (阿姆斯壯數)
409 字串與檔案處理 (字串加密)
[課堂重點]
509 字串拆解
[今日作業]
306~310
作者:
何若恩
時間:
2025-5-2 20:18
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
int a, b, c;
float ans;
cin>>a>>b>>c;
if(a>=60 and a<100){
cout<<"1"<<endl;
}else{
cout<<"0"<<endl;
}
ans=(b+1)/10.0;
printf("%.2f",ans);
cout<<endl;
if(a>=c){
cout<<a;
}else{
cout<<c;
}
return 0;
}
複製代碼
作者:
何若恩
時間:
2025-5-2 20:22
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
int n;
cin>>n;
if(n==1){
cout<<"one";
}else if(n==2){
cout<<"two";
}else if(n==3){
cout<<"three";
}else if(n==4){
cout<<"four";
}else{
cout<<"error";
}
return 0;
}
複製代碼
作者:
何若恩
時間:
2025-5-2 20:29
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
ifstream ifs;
ofstream ofs;
ifs.open("C:\\Users\\student\\read.txt");
ofs.open("C:\\Users\\student\\write.txt");
string s;
getline(ifs,s);
for(int i=0;i<s.size();i++){
s[i]=s[i]+2;
}
cout<<s<<endl;
ofs<<s;
return 0;
}
複製代碼
作者:
何若恩
時間:
2025-5-2 20:59
#include <bits/stdc++.h>
using namespace std;
int compute(int n){
int all=0;
for(int i=1;i<n;i++){
int a=0;
string s=to_string(i);
for(int j=0;j<s.size();j++){
a+=pow(s[j]-'0', s.size());
}
if(i==a){
cout<<i<<endl;
all+=i;
}
}
return all;
}
int main(int argc, char** argv) {
int n;
cin>>n;
cout<<compute(n);
return 0;
}
複製代碼
作者:
何若恩
時間:
2025-5-2 21:32
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
int a;
string s;
getline(cin, s);
replace(s.begin(),s.end(),'/',' ');
cout<<s<<endl;
stringstream ss(s);
int num, sum=0;
while(ss>>num){
sum += num;
}
cout<<sum;
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2