返回列表 發帖

2025/5/2 課堂重點(若恩)

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main(int argc, char** argv) {
  4.     int a, b, c;
  5.     float ans;
  6.     cin>>a>>b>>c;
  7.     if(a>=60 and a<100){
  8.         cout<<"1"<<endl;
  9.     }else{
  10.         cout<<"0"<<endl;
  11.     }
  12.     ans=(b+1)/10.0;
  13.     printf("%.2f",ans);
  14.     cout<<endl;
  15.     if(a>=c){
  16.         cout<<a;
  17.     }else{
  18.         cout<<c;
  19.     }
  20.         return 0;
  21. }
複製代碼

TOP

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main(int argc, char** argv) {
  4.     int n;
  5.     cin>>n;
  6.     if(n==1){
  7.         cout<<"one";
  8.     }else if(n==2){
  9.         cout<<"two";
  10.     }else if(n==3){
  11.         cout<<"three";
  12.     }else if(n==4){
  13.         cout<<"four";
  14.     }else{
  15.         cout<<"error";
  16.     }
  17.         return 0;
  18. }
複製代碼

TOP

  1. #include <bits/stdc++.h>
  2. using namespace std;

  3. int main(int argc, char** argv) {
  4.     ifstream ifs;
  5.     ofstream ofs;
  6.     ifs.open("C:\\Users\\student\\read.txt");
  7.     ofs.open("C:\\Users\\student\\write.txt");
  8.     string s;
  9.     getline(ifs,s);
  10.     for(int i=0;i<s.size();i++){
  11.         s[i]=s[i]+2;
  12.     }
  13.     cout<<s<<endl;
  14.     ofs<<s;
  15.     return 0;
  16. }
複製代碼

TOP

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int compute(int n){
  4.     int all=0;
  5.     for(int i=1;i<n;i++){
  6.         int a=0;
  7.         string s=to_string(i);
  8.         for(int j=0;j<s.size();j++){
  9.             a+=pow(s[j]-'0', s.size());
  10.         }
  11.         if(i==a){
  12.             cout<<i<<endl;
  13.             all+=i;
  14.         }
  15.     }
  16.     return all;
  17. }
  18. int main(int argc, char** argv) {
  19.     int n;
  20.     cin>>n;
  21.     cout<<compute(n);
  22.     return 0;
  23. }
複製代碼

TOP

  1. #include <bits/stdc++.h>
  2. using namespace std;

  3. int main(int argc, char** argv) {
  4.     int a;
  5.     string s;
  6.     getline(cin, s);
  7.     replace(s.begin(),s.end(),'/',' ');
  8.     cout<<s<<endl;
  9.     stringstream ss(s);
  10.     int num, sum=0;
  11.     while(ss>>num){
  12.         sum += num;
  13.     }
  14.     cout<<sum;
  15.     return 0;
  16. }
複製代碼

TOP

返回列表