zoukankan      html  css  js  c++  java
  • 密码破译

    1、基础篇

    将A->Z,B->Y,C->X……;a->z,b->y,c->x……;即第1个字母变成第26个字母,第i个字母变成第(26-i+1)个字母,非字母字符不变。

    程序如下:

     1 #include <stdio.h>
     2 #include <stdlib.h>
     3 int main()
     4 {
     5     int j=0,n;
     6     char a[100],b[100];
     7     
     8     printf("enter the code:
    ");
     9     gets(a);
    10     printf("
    cipher code  :%s",a);
    11     //j=0;
    12     while(a[j]!=''){
    13         if((a[j]>='A')&&(a[j]<='Z')){
    14             a[j]=155-a[j];//26-i+1,其中i=a[j]-64;因此b[j]=26-(a[j]-64)+1+64=155-a[j];
    15         }
    16         else if((a[j]>='a')&&(a[j]<='z')){
    17             a[j]=219-a[j];//26-i+1,其中i=a[j]-96;因此b[j]=26-(a[j]-96)+1+96=219-a[j];
    18         }
    19         else a[j]=a[j];
    20         j++;
    21     }
    22     n=j;
    23     printf("
    original code is :");
    24     for(j=0;j<n;j++)
    25         putchar(a[j]);
    26     system("pause");
    27     return 0;
    28 }
  • 相关阅读:
    Spring的AOP深入理解
    枚举和注解学习笔记
    单例模式
    工厂设计模式
    网络编程
    多线程笔记
    IOI2021集训队作业
    计蒜客 mark
    51nod mark
    关于此博客
  • 原文地址:https://www.cnblogs.com/crystalmoore/p/5924203.html
Copyright © 2011-2022 走看看