ITMISS
我亲手写的。#include<stdio.h>#include<stdlib.h>int get_len(char *);void rp_last(char* , char* , char* );int get_len(char* str){if(str == NULL) return -1;int i;for(i=0;str[i];i++);return i;}void rp_last(char *s,char *sub1,char *sub2){int i,j;int k;int sLen;int sub1Len;int sub2Len;sLen=get_len(s);sub1Len=get_len(sub1);sub2Len=get_len(sub2);for(i=sLen-1;i>=0;i--){for(j=sub1Len-1,k=i;j>=0&&k>=0;j--,k--)if(s[k]!=sub1[j]) break;if(j<0) break;}//printf("%d\n",i);if(j>=0)printf("not found!\n");else if(sub1Len>sub2Len){k=sub1Len-sub2Len;for(j=i+1;s[j-k]=s[j];j++);for(j=sub2Len-1;j>=0;j--,i--)s[i-k]=sub2[j];}else{k=sub1Len-sub2Len;s[k+sLen]='\0';for(j=sLen-1;j>i;j--)s[j+k]=s[j];for(j=sub2Len-1;j>=0;j--,i--)s[i+k]=sub2[j];}printf("result:%s\n",s);return ;}void main(){char s[256];char sub1[100];char sub2[100];printf("s :");gets(s);printf("sub1:");gets(sub1);printf("sub2:");gets(sub2);rp_last(s,sub1,sub2);return ;}