C语言求教! 30

 我来答
千锋教育
2015-12-03 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
展开全部


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void fun(char *string,int a){
string[a]='w';
string[a+1]='e';

int i;
for(i=(a+3);i<strlen(string)-1;i++){
string[i-1]=string[i];


}
string[strlen(string)-1]='\0';
}


int main(void) {
char str[1000];
char sub[3]="you";
int len;
int i;
gets(str);
len=strlen(str);
for(i=0;i<len;){


if((str[i]==sub[0])&&(str[i+1]==sub[1])&&(str[i+2]==sub[2])){

fun(str,i);
i=i+2;
puts(str);
     len--;
}
i++;
}










puts("end");
return EXIT_SUCCESS;
}
更多追问追答
追问
表示看不懂
请不要用函数,也不要用指针
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
哥们儿会_臭臭
2015-12-03 · TA获得超过876个赞
知道小有建树答主
回答量:421
采纳率:50%
帮助的人:178万
展开全部
#include<stdio.h>
#include<string.h>
int isLetter(char c){
    if(c>='a' && c<='z') return 1;
    if(c>='A' && c<='Z') return 1;
    return 0;
}
int combine(char *dst,char *scr){
    int i;
    for(i=0;scr[i];i++)
        if(isLetter(scr[i]))
            dst[i]=scr[i];
        else
            break;
    dst[i]='\0';
    return i;
}
int main(){
    char c[1024],w[1024];
    int i;
    while(gets(c)!=NULL){
        for(i=0;c[i];i++){
            if(isLetter(c[i])==0){
                printf("%c",c[i]);
                continue;
            }
            i+=combine(w,c+i)-1;
            if(strcmp(w,"you")==0)
                printf("we");
            else
                printf("%s",w);
        }
        printf("\n");
    }
    return 0;
}
更多追问追答
追问
还不会用指针
追答
#include<stdio.h>
#include<string.h>
int isLetter(char c){
    if(c>='a' && c<='z') return 1;
    if(c>='A' && c<='Z') return 1;
    return 0;
}
int main(){
    char c[1024],w[1024];
    int i,j;
    while(gets(c)!=NULL){
        for(i=0;c[i];i++){
            if(isLetter(c[i])==0){
                printf("%c",c[i]);
                continue;
            }
            for(j=0;c[i+j];j++)
                if(isLetter(c[i+j]))
                    w[j]=c[i+j];
                else
                    break;
            w[j]='\0';
            i+=j-1;
            if(strcmp(w,"you")==0)
                printf("we");
            else
                printf("%s",w);
        }
        printf("\n");
    }
    return 0;
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
一变班爱麻啊堡0J
高粉答主

2020-01-13 · 醉心答题,欢迎关注
知道答主
回答量:11.4万
采纳率:2%
帮助的人:5397万
展开全部
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式