返回列表 發帖

2025/4/12冠毅

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

  3. int main()
  4. {
  5.     int a;
  6.     cin>>a;
  7.     if(a<0 or a>100){
  8.         cout<<"error"<<endl;

  9.     }else if(a>=0 or a<=100){
  10.         if(a<=60){
  11.             cout<<"fail"<<endl;
  12.         }else if(a>60){
  13.             cout<<"pass"<<endl;
  14.         }

  15.         if(a%2==0){
  16.             cout<<"even";
  17.         }else{
  18.             cout<<"odd";
  19.     }



  20.     }


  21.     return 0;
  22. }
複製代碼

TOP

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

  3. int main()
  4. {
  5.     int a,b=0;
  6.     cin>>a;
  7.     for(int i=2;i<a;i++){


  8.         for(int o=2;o<=i-1;o++){

  9.             if(i%o==0){
  10.                 b=1;
  11.                 break;

  12.             }


  13.         }
  14.         if(b==0){
  15.             cout<<i<<" ";

  16.         }
  17.         b=0;
  18.     }








  19.     return 0;
  20. }
複製代碼

TOP

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

  3. void compute(int n){


  4.     int a[11]={0};
  5.     a[0]=0;
  6.     a[1]=1;
  7.     for(int i=2;i<=n;i++){
  8.         a[i]=a[i-1]+a[i-2];

  9.     }
  10.     for(int i=n;i>=1;i--){
  11.         cout<<"fib"<<"("<<i<<")"<<"="<<a[i]<<endl;


  12.     }




  13. }


  14. int main()
  15. {

  16.     int i;
  17.     cin>>i;
  18.     if(i<10){
  19.         compute(i);

  20.     }




  21.     return 0;
  22. }
複製代碼

TOP

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4.     int i;
  5.     cin>>i;
  6.     if(i%2==0){
  7.         cout<<"even";
  8.     }else {
  9.         cout<<"odd";
  10.     }
  11.         return 0;
  12. }
複製代碼
201

TOP

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4.     int i;
  5.     cin>>i;
  6.     if(i>100 or i<0){
  7.         cout<<"error";
  8.     }else{
  9.         if(i>60){
  10.             cout<<i+10;
  11.         }else {
  12.             cout<<i+5;
  13.         }
  14.         
  15.     }
  16.    
  17.         return 0;
  18. }
複製代碼

TOP

本帖最後由 劉冠毅 於 2025-4-19 13:53 編輯
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4.     char i;
  5.     cin>>i;
  6.     if(i=='1'){
  7.         cout<<"one";
  8.     }else if(i=='2'){
  9.         cout<<"two";
  10.    
  11.     }else if (i=='3'){
  12.         cout<<"three";
  13.     }else if(i=='4'){
  14.         cout<<"four";
  15.     }else if(i>'4' or i<'0'){
  16.         cout<<"error";
  17.     }
  18.         
  19.    
  20.    
  21.         return 0;
  22. }
複製代碼

TOP

本帖最後由 劉冠毅 於 2025-4-19 13:56 編輯
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4.     char i;
  5.     int u,o;
  6.     cout<<"符號";
  7.     cin>>i;
  8.     cout<<"數字";
  9.     cin>>u>>o;
  10.     if(i=='+'){
  11.         cout<<u+o;
  12.     }else if(i=='-'){
  13.         cout<<u-o;

  14.     }else if (i=='*'){
  15.         cout<<u*o;
  16.     }else {
  17.         cout<<"error";
  18.     }



  19.         return 0;
  20. }
複製代碼

TOP

本帖最後由 劉冠毅 於 2025-4-19 13:56 編輯
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4.     int o[7];
  5.     for(int u=1;u<0;u++){
  6.         char i;
  7.         cin>>i;
  8.         if(i=='1'){
  9.             o[0]++;
  10.         }else if(i=='2'){
  11.             o[1]++;
  12.         }else if(i=='3'){
  13.             o[2]++;
  14.         }else if(i=='4'){
  15.             o[3]++;
  16.         }else if(i=='5'){
  17.             o[4]++;
  18.         }else if(i=='6'){
  19.             o[5]++;
  20.         }else{
  21.             o[6]++;
  22.         }
  23.         
  24.     }
  25.     for(int i=0;i<5;i++){
  26.         cout<<"number"<<i+1<<":"<<o[i]<<endl;
  27.     }
  28.     cout<<"error"<<o[6];
  29.         
  30.    
  31.    
  32.         return 0;
  33. }
複製代碼

TOP

返回列表