实验10

#include<stdio.h>
void getx(char *c1);
void getr(char *c2);
void main()
{
    char z[100];
    puts("Enter a string:");
    gets(z);
    getx(z);
}
void getx(char *c1)
{
    int n=0;
    int k=0;
    int j=0;
    char b[100];
    puts("Enter an integer:");
    scanf("%d",&n);
    while(*(c1+j)!='')
    {j++;}
    for(int i=j-n;i<j;i++)
    {b[k]=*(c1+i);
    k++;}
    b[k]='';
    getr(b);
    puts("The new string is ");
    puts(b);
}
void getr(char *c2)
{
    int i=0;
    char b[100];
    while(*(c2+i)!='')
    {i++;}
    for(int j=0;j<i;j++)
    {b[i-j-1]=*(c2+j);}
    for(int k=0;k<i;k++)
    {*(c2+k)=b[k];}
}
#include<stdio.h>
#include<string.h>
#define MAXLINE 100
void encrypt(char*);
int main(void)
{
    char line[MAXLINE];
    
    printf("Input the string:");
    gets(line);
    encrypt(line);
    printf("%s%s
","After being encrypted:",line);
    return 0;
}
void encrypt(char *s)
{
    for(;*s!='';s++)
      if(*s=='z')
      *s='a';
      else
      *s=*s+1;
}
#include<stdio.h>
#include<string.h>
void main()
{
    int n;
    char str1[50];
    str2[]={"es"};
    str3[]={"s"};
    printf("请输入一个英文名词:");
    gets(str1);
    n=strlen(str1);
    if(str1[n-1]=='y')
    {
    str1[n-1]='i';
    printf("它的复数形式为:%s
",strcat(str1,str2));
    }
    else if(str1[n-1]=='s'||str1[n-1]=='x'||(str1[n-2]=='c'&&str1[n-1]=='h')||(str1[n-2]=='s'&&str1[n-1]=='h'))
    {
    printf("它的复数形式为:%s
",strcat(str1,str2));
    }
    else if(str1[n-1]=='o')
    {
    printf("它的复数形式为:%s
",strcat(str1,str2));
    }
    else
    {
    printf("它的复数形式为:%s
",strcat(str1,str3));
    }
}
原文地址:https://www.cnblogs.com/chaptercold/p/3417460.html