-
-
Save GZShi/3803322 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define c1(c) ((((c) << 1) & 0x2a) | (((c) >> 1) & 0x15)) // 交换 | |
#define c2(c) ((c) >> 6) // 循环左移位数 | |
#define c3(c) ((c1((c)) >> 6 - c2((c))) | ((c1((c)) << c2((c))) & 0x3f) | ((c) & 0xc0)) //循环 | |
void encode(char *s); | |
int main(void) | |
{ | |
char instr[200]; | |
puts("input a string:"); | |
gets(instr); | |
encode(instr); | |
puts(instr); | |
return 0; | |
} | |
void encode(char *s) | |
{ | |
int i = 0; | |
while(s[i] != '\0') | |
s[i++] = (c3(s[i])); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment