本帖最后由 Mike_zh 于 2014-12-6 00:29 编辑
这道题我是这样做的- #include<stdio.h>
- #include<stdlib.h>
- #define MAXLEN 100
- char *encode(char *s)
- {
- char *p =(char *)calloc(MAXLEN,sizeof(char));
- char *q = p;
- while(*s)
- {
- if(*s>=65&&*s<=90)
- {
- char val = *s;
- *q++ = (val-65+1)%26+65;
- *q++ = (val-65+2)%26+65;
- *q++ = (val-65+3)%26+65;
- }
- if(*s>=97&&*s<=122)
- {
- char val = *s;
- *q++ = (val-97+1)%26+97;
- *q++ = (val-97+2)%26+97;
- *q++ = (val-97+3)%26+97;
- }
- else
- {
- *q++ = *s;
- }
- s++;
- }
- *q='\0';
- return p;
- }
- int main()
- {
- printf("hello234World加密后:%s\n",encode("hello234World"));
- return 0;
- }
复制代码
希望对你有帮助
|