C++编程问题求解编写一个程序,将字符串“Love”译成密码,译码方法采用替换加密法,其加密规则是:将原来的字母用字母表

1个回答

  • #include

    int main()

    {

    char cypher[4]="Love",code[4];

    const int N=26;

    int i=0,n;

    printf("please input the keys :n");

    scanf("%d",&n);

    printf("The original word is %s n", cypher);

    for(;i'Z')

    cypher[i] =((cypher[i] - 'a')+n)%N+'a';

    else

    cypher[i]=((cypher[i] - 'A')+n)%N+'A';

    }

    printf(("The encrypted word is %s , cypher);

    return 0;

    }