#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define N 3
void code(char *pstr)
{
char *p=pstr;
while('\0'!=*p)
{
if(*p>='a'&&*p<='z')
{
*p=(26-(*p-'a')-1)+'a';
}
if(*p>='A'&&*p<='B')
{
*p=(26-(*p-'A')-1)+'A';
}
p++;
}
}
int main()
{
char s[100];
scanf("%s",s);
code(s);
printf("%s",s);
}
将字符串联系起来
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define N 3
void strcat(char *pstr1,char *pstr2)
{
int strlength1=0;
char *p=pstr1;
while(*p!='\0')
{
p++;
strlength1++;
}
p=pstr2;
while(*p!='\0')
{
pstr1[strlength1]=*p;
p++;
strlength1++;
}
pstr1[strlength1]='\0';
printf("%s",pstr1);
}
int main()
{
char pstr1[100];
char pstr2[50];
scanf("%s %s",pstr1,pstr2);
strcat(pstr1,pstr2);
}