C语言题目单词有多少,题目 - 例题(12.8) 单词替换 C语言

共回答了23个问题采纳率:87%

#include

#include

#include

#define MAX 1000

#define LEN 20

void Input (char *a, char *b, char *c){

gets(a);

gets(b);

gets(c);

}

void Swap (char *str, char *FindWord, char *SwapWord){

int j,s,k,i=0,SwapWordLength,strLength,FindWordLength,n;

char *p1,*p2;

p1=str;

p2=FindWord;

strLength=strlen(str); //length of the original sentence

FindWordLength=strlen(FindWord); //length of the old word

SwapWordLength=strlen(SwapWord); //length of the new word

n=SwapWordLength-FindWordLength;

while(*p1!=' '){

if((*p1==*p2)&&(!isalpha(*(p1-1)))) //isalpha : judge whether the char_c is an english word or not,if yes return !0,if no return 0

while((*p1==*p2)&&(*p2!=' '))

{ p1++; p2++; i++; } //i: record how many chars has been read

else { p1++; i++; }

if((*p2==' ')&&(isalpha(*p1)==0)){

//find the old word in the sentence

if(n

1年前

1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值