5 条题解

  • 1
    @ 2025-12-20 14:05:07
    #include <iostream>
    using namespace std;
    short a,b;
    int main()
    {
    	cin >> a >> b;
    	switch (a + b)
    	{
    		case 1:cout << "one";break;
    		case 2:cout << "two";break;
    		case 3:cout << "three";break;
    		case 4:cout << "four";break;
    		case 5:cout << "five";break;
    		case 6:cout << "six";break;
    		case 7:cout << "seven";break;
    		case 8:cout << "eight";break;
    		case 9:cout << "nine";break;
    		default:cout << "None";
    	}
    	return 0;
    }
    • 1
      @ 2023-2-9 18:48:44
      #include<iostream>
      using namespace std;
      int main(){
      	int a,b;
      	string n[10]={"","one","two","three","four","five","six","seven","eight","nine"};
      	cin>>a>>b;
      	if(0<a+b&&a+b<10)cout<<n[a+b];
      	else cout<<"None";
      	return 0;
      }
      
      • 0
        @ 2025-9-28 13:22:34
        #include <iostream>
        using namespace std;
        int a, b, c;
        string str[10] = {"None", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
        int main()
        {
        	cin >> a >> b;
        	if(a + b > 0 && a + b < 10)
        		c = a + b;
        	cout << str[c] << endl;
        	return 0;
        }
        
        • 0
          @ 2025-5-6 22:38:14

          介绍两种做法: 1.数组打表

          #include<bits/stdc++.h>
          using namespace std;
          const int N=1e5+5,INF=0x3f3f3f3f;
          typedef long long LL;
          int a,b;
          string ans[]={"","one","two","three","four","five","six","seven","eight","nine","None"};
          int main(){
          	cin>>a>>b;
          	if(a+b>0&&a+b<10)cout<<ans[a+b];
          	else cout<<ans[10];
          	return 0;
          }
          

          2.switch-case

          #include<bits/stdc++.h>
          using namespace std;
          const int N=1e5+5,INF=0x3f3f3f3f;
          typedef long long LL;
          int a,b;
          int main(){
          	cin>>a>>b;
          	switch(a+b){
          		case 1:cout<<"one";break;
          		case 2:cout<<"two";break;
          		case 3:cout<<"three";break;
          		case 4:cout<<"four";break;
          		case 5:cout<<"five";break;
          		case 6:cout<<"six";break;
          		case 7:cout<<"seven";break;
          		case 8:cout<<"eight";break;
          		case 9:cout<<"nine";break;
          		default:cout<<"None";break;
          	}
          	return 0;
          }
          
          • @ 2025-5-6 22:38:49

            这本来是switch-case的裸题

        • -1
          @ 2024-5-10 20:51:41

          #include using namespace std; int main(){ int a,b; cin>>a>>b; if(a+b1){ cout<<"one"; } else if(a+b2){ cout<<"two"; } else if(a+b3){ cout<<"three"; } else if(a+b4){ cout<<"four"; } else if(a+b5){ cout<<"five"; } else if(a+b6){ cout<<"six"; } else if(a+b7){ cout<<"seven"; } else if(a+b8){ cout<<"eight"; } else if(a+b==9){ cout<<"nine"; } else{ cout<<"None"; } return 0;

          }

          • 1

          信息

          ID
          875
          时间
          1000ms
          内存
          128MiB
          难度
          5
          标签
          递交数
          228
          已通过
          94
          上传者