|
|
发表于 2018-4-10 17:07:32
|
显示全部楼层
- // EnctryStr.cpp: 定义控制台应用程序的入口点。
- //
- #include "stdafx.h"
- #pragma warning(disable : 4996)
- #include <stdio.h>
- #include <stdlib.h>
- #define ARR_SIZE 10
- int main(void) {
- char str[ARR_SIZE] = { 0 };
- printf("Enter encrypted the string :");
- scanf("%s", str);
- for (int i = 0; i < ARR_SIZE; i++) {
- if ((str[i] >= 'A'&& str[i] <= 'Z') || (str[i] >= 'a' && str[i] <= 'z')) {
- //str[i] += 4;
- switch ( str[ i ] ) {
- case 'z':
- str[i] = 'd';
- break;
- case 'Z':
- str[i] = 'D';
- break;
- case 'y':
- str[i] = 'c';
- break;
- case 'Y':
- str[i] = 'C';
- break;
- case 'x':
- str[i] = 'b';
- break;
- case 'X':
- str[i] = 'B';
- break;
- case 'w':
- str[i] = 'a';
- break;
- case 'W':
- str[i] = 'A';
- break;
- default:
- str[i] = str[i] + 4;
- break;
- }
- }
- }
- for (int i = 0; i < ARR_SIZE; i++) {
- if (str[i] == 'W' || str[i] == 'w') {
- if (str[i] == 'W') {
- str[i] = 'A';
- }
- else {
- str[i] = 'a';
- }
- }
- else if (str[i] == 'X' || str[i] == 'x') {
- if (str[i] == 'X') {
- str[i] = 'B';
- }
- else {
- str[i] = 'b';
- }
- }
- else if (str[i] == 'Y' || str[i] == 'y') {
- if (str[i] == 'Y') {
- str[i] = 'C';
- }
- else {
- str[i] = 'c';
- }
- }
- else if (str[i] == 'Z' || str[i] == 'z') {
- if (str[i] == 'Z') {
- str[i] = 'D';
- }
- else {
- str[i] = 'd';
- }
- }
- }
- printf("string to is :%s", str);
- system("pause");
- return 0;
- }
复制代码 |
|