main()中接收需要加密的字符串,加密时,字符指针+1,Encrpy参数为字符指针, 解密时-1,Decrpy参数也是字符指针
#include <iostream>
#include<cstring>
#include<cmath>
using namespace std;
void Encrpy(char *p){
int n=strlen(p);
for(int i=0;i<n;i++){
//cout<<strlen(p)<<endl;
*p=*p+1;
p++;
}
}
void Decrpy(char *p){
int n=strlen(p);
for(int i=0;i<n;i++){
*p=*p-1;
p++;
}
}
int main()
{
char str[20];
char *p;
cout<<"输入字符串:";
cin>>str;
p=str;
//cout<<"源字符串:"<<p<<endl;
Encrpy(p);
cout<<"加密结果:"<<p<<endl;
Decrpy(p);
cout<<"解密结果:"<<p<<endl;
return 0;
}