1 int Afan(char a); 2 3 int main() 4 5 { 6 7 char arr[40] = {"aABX"}; 8 9 scanf("%s", arr); 10 11 printf("原电文:%s\n", arr); 12 13 //加密电文 14 //注释:如对代码建议请联系QQ:466449822 15 char m_arr[40] = "aaa"; 16 17 printf("密电文:"); 18 19 for (int i = 0; i < strlen(arr) + 1; i++) 20 21 { 22 23 if ((arr[i] >65 - 1 && arr[i] < 90 + 1) || (arr[i] >97 - 1 && arr[i] < 122 + 1)) 24 { 25 arr[i] = Afan(arr[i]); 26 27 } 28 printf("%c", arr[i]); 29 30 } 31 32 while (1); 33 34 return 0; 35 36 } 37 38 39 int Afan(char a) 40 41 { char over; 42 43 char zm[27] = { ‘A‘, ‘B‘, ‘.‘, ‘.‘, ‘Z‘ }; 44 if (a > 64 && a < 91) 45 { 46 for (int i = 65; i < 90 + 1; i++) 47 { int j; 48 j = i - 64; 49 zm[j] = i; 50 } 51 } 52 if (a > 96 && a < 123) 53 { 54 for (int i = 97; i < 122 + 1; i++) 55 { 56 int j; 57 j = i - 96; 58 zm[j] = i; 59 } 60 } 61 for (int i = 0; i < 27; i++) 62 { 63 if (a == zm[i]) 64 65 { 66 over = zm[26 - i + 1]; 67 } 68 } 69 return over; 70 }
结果:
原文地址:https://www.cnblogs.com/maye426/p/9434177.html
时间: 2024-10-10 16:29:44