2 条题解

  • 0
    @ 2025-12-15 0:31:45
    #include <stdio.h>
    
    int main() {
        // 预设正确的账户和密码
        char correct_account = 'z';
        int correct_password = 123;
    
        // 定义变量存储用户输入的账户和密码
        char input_account;
        int input_password;
    
        // 读取用户输入的账户(char类型),注意%c前加空格可跳过换行/空白符干扰
        scanf(" %c", &input_account);
        // 读取用户输入的密码(int类型)
        scanf("%d", &input_password);
    
        // 条件判断逻辑
        if (input_account == correct_account && input_password == correct_password) {
            // 账户和密码都正确
            printf("欢迎\n");
        } else if (input_account != correct_account && input_password != correct_password) {
            // 账户和密码都错误
            printf("账户密码错误\n");
        } else if (input_account != correct_account) {
            // 仅账户错误(密码正确)
            printf("账户错误\n");
        } else {
            // 仅密码错误(账户正确)
            printf("密码错误\n");
        }
    
        return 0;
    }
    
    • 0
      @ 2023-10-11 20:24:49

      #include <stdio.h>

      int main() { char account; int password;

      scanf("%c", &account);
      scanf("%d", &password);
      
      if (account == 'z' && password == 123) {
          printf("欢迎\n");
      } else if (account == 'z' && password != 123) {
          printf("密码错误\n");
      } else if (account != 'z' && password == 123) {
          printf("账户错误\n");
      } else {
          printf("账户密码错误\n");
      }
      
      return 0;
      

      }

      • 1

      信息

      ID
      55
      时间
      1000ms
      内存
      256MiB
      难度
      6
      标签
      (无)
      递交数
      2610
      已通过
      800
      上传者