鱼C论坛

 找回密码
 立即注册
查看: 2610|回复: 6

[已解决]求完善的代码

[复制链接]
发表于 2018-4-10 17:07:32 | 显示全部楼层
  1. // EnctryStr.cpp: 定义控制台应用程序的入口点。
  2. //

  3. #include "stdafx.h"
  4. #pragma warning(disable : 4996)
  5. #include <stdio.h>
  6. #include <stdlib.h>

  7. #define ARR_SIZE 10

  8. int main(void) {

  9.         char str[ARR_SIZE] = { 0 };

  10.         printf("Enter encrypted the string :");
  11.         scanf("%s", str);

  12.         for (int i = 0; i < ARR_SIZE; i++) {
  13.                 if ((str[i] >= 'A'&& str[i] <= 'Z') || (str[i] >= 'a' && str[i] <= 'z')) {
  14.                         //str[i] += 4;
  15.                         switch ( str[ i ] ) {
  16.                                 case 'z':
  17.                                         str[i] = 'd';
  18.                                         break;
  19.                                 case 'Z':
  20.                                         str[i] = 'D';
  21.                                         break;
  22.                                 case 'y':
  23.                                         str[i] = 'c';
  24.                                         break;
  25.                                 case 'Y':
  26.                                         str[i] = 'C';
  27.                                         break;
  28.                                 case 'x':
  29.                                         str[i] = 'b';
  30.                                         break;
  31.                                 case 'X':
  32.                                         str[i] = 'B';
  33.                                         break;
  34.                                 case 'w':
  35.                                         str[i] = 'a';
  36.                                         break;
  37.                                 case 'W':
  38.                                         str[i] = 'A';
  39.                                         break;
  40.                                 default:
  41.                                         str[i] = str[i] + 4;
  42.                                         break;
  43.                         }
  44.                 }
  45.         }

  46.         for (int i = 0; i < ARR_SIZE; i++) {
  47.                 if (str[i] == 'W' || str[i] == 'w') {
  48.                         if (str[i] == 'W') {
  49.                                 str[i] = 'A';
  50.                         }
  51.                         else {
  52.                                 str[i] = 'a';
  53.                         }
  54.                 }
  55.                 else if (str[i] == 'X' || str[i] == 'x') {
  56.                         if (str[i] == 'X') {
  57.                                 str[i] = 'B';
  58.                         }
  59.                         else {
  60.                                 str[i] = 'b';
  61.                         }
  62.                 }
  63.                 else if (str[i] == 'Y' || str[i] == 'y') {
  64.                         if (str[i] == 'Y') {
  65.                                 str[i] = 'C';
  66.                         }
  67.                         else {
  68.                                 str[i] = 'c';
  69.                         }
  70.                 }
  71.                 else if (str[i] == 'Z' || str[i] == 'z') {
  72.                         if (str[i] == 'Z') {
  73.                                 str[i] = 'D';
  74.                         }
  75.                         else {
  76.                                 str[i] = 'd';
  77.                         }
  78.                 }
  79.         }

  80.         printf("string to is :%s", str);
  81.         system("pause");
  82.         return 0;
  83. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-27 03:57

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表