1 条题解

  • 0
    @ 2023-6-11 12:24:20

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
    	char a;
    	cin>>a;
    	if(a >= 'A' && a <= 'Y'|| a>='a' && a <= 'y'){
    		a = a + 1;
    	}else if(a == 'z'){
    		a = 'a';
    	}else if(a == 'Z'){
    		a = 'A';
    	}
    	cout<<a;
    }
    
    
    

    Java :

    import java.util.Scanner;
    public class Main {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            while (scanner.hasNext()) {
                String a=scanner.next(); //输入字符
                char[] b=a.toCharArray();  //转换为字符串
                for(int i=0;i<b.length;i++){
                if(b[i]>='a'&&b[i]<'z' || b[i]>='A'&&b[i]<'Z') //判断位置
                    {
                        b[i]++;   //向前移位
                    }
                if(b[i]=='z' || b[i]=='Z')
                {
                    b[i]=(char) (b[i]-25); //从z转换为a
                }
                System.out.print(b[i]+" ");
                }
            }
        }
    }
    

    Python :

    n=ord(input())+1
    if n!=123 and n!=91:
        print(chr(n))
    elif n==123:
        print('a')
    else:
        print('A')
    
    • 1

    信息

    ID
    2789
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者