1 条题解

  • 1
    @ 2023-6-11 12:24:21

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
    	string s;
    	getline(cin,s);
    	for(int i = 0;i < s.size();i++){
    		s[i] = tolower(s[i]);
    		
    		if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u'){
    			s[i] = toupper(s[i]);
    		}else{
    			s[i] = tolower(s[i]);
    		}
    	}
    	cout<<s;
    	return 0;
    }
    
    

    Java :

    import java.util.Scanner;
    
    public class Main{
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String x = sc.nextLine();
            char c;
            String s;
            s = x.toLowerCase();
            for (int i = 0; i < s.length(); i++) {
                c = s.charAt(i);
                if (c == 97) {
                    System.out.print('A');
                } else if (c == 101) {
                    System.out.print('E');
                } else if (c == 105) {
                    System.out.print('I');
                } else if (c == 111) {
                    System.out.print('O');
                } else if (c == 117) {
                    System.out.print('U');
                } else {
                    System.out.print(c);
                }
    
            }
    
        }
    }
    
    • 1

    【入门】元音字母转大写辅音字母转小写

    信息

    ID
    2801
    时间
    1000ms
    内存
    64MiB
    难度
    10
    标签
    递交数
    3
    已通过
    1
    上传者