2 条题解

  • 0
    @ 2024-1-4 22:01:18
    #include <stdio.h>
    #include <string.h>
    void reversethree1(char x[])
    {
        char s[27] = { "0" };
        s[1] = 'a';
        for (int i = 2; i <= 26; i++) {
            s[i] = s[i - 1] + 1;
        }
            for (int j = 1; j <= 26; j++) {
                if (*x == s[j] && j + 3 > 26) {
                    *x = s[j + 3 - 26];
                    break;
                }
                else if (*x== s[j] && j + 3 <= 26) {
                    *x= s[j + 3];
                    break;
                }
            }
    }
    void reversethree2(char x[])
    {
        char s1[27] = { "0" };
        s1[1] = 'A';
        for (int i = 2; i <= 26; i++) {
            s1[i] = s1[i - 1] + 1;
        }
            for (int j = 1; j <= 26; j++) {
                if (*x == s1[j] && j + 3 > 26) {
                    *x = s1[j + 3 - 26];
                    break;
                }
                else if (*x == s1[j] && j + 3 <= 26) {
                    *x = s1[j + 3];
                    break;
                }
            }
    }
    void swap(char x[],char y[])
    {
        char s='0';
        s = *x;
        *x = *y;
        *y = s;
    }
    void exchange(char x[])
    {
        if (*x>'Z') {
            *x -= 32;
        }
        else {
            *x += 32;
        }
    }
    int main()
    {
        int i;
        char s[50] = { "0" };
        scanf("%s", s);
        for (i = 0; i < strlen(s); i++) {
            if (s[i] > 'Z') {
                reversethree1(&s[i]);
            }
            else {
                reversethree2(&s[i]);
            }
        }
        for(i=0;i<strlen(s)/2;i++){
            swap(&s[i],&s[strlen(s)-1-i]);
        }
        for (i = 0; i < strlen(s); i++) {
            exchange(&s[i]);
        }
        printf("%s\n", s);
        return 0;
    }
    
    
    
    
    • 0
      @ 2023-9-23 13:07:08
      import java.util.Scanner;
      
      public class Main {
          public static void main(String[] args) {
              final Scanner scanner = new Scanner(System.in);
              final String crypto = scanner.nextLine();
              final StringBuilder result = new StringBuilder();
              for (int i = crypto.length() - 1; i >= 0; i--) {
                  int index = crypto.charAt(i);
      
                  //rightMove
                  index += 3;
                  if ((index > 90 && index < 97) || index > 122) {
                      index -= 26;
                  }
      
                  //upperLowerConvert
                  if (index < 97) {
                      index += 32;
                  } else {
                      index -= 32;
                  }
      
                  result.append((char) index);
              }
              System.out.println(result);
          }
      }
      
      • 1

      信息

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