當前位置:編程學習大全網 - 編程軟體 - 求數據結構 文章編輯**的源程序(用C語言編寫)

求數據結構 文章編輯**的源程序(用C語言編寫)

給妳實現了要求得功能函數,由於對妳問題得壹頁得概念不理解,用壹字符指針代替文章來操作,約定以'\0'來結束,下面所有得函數都是接受1個字符指針來進行操作,參數傳入傳出參照微軟格式.

----------------------------------

/*

統計文章*pt中英文字母得數量*pNum

空格數*pNumSpace,總字數*pNumAll

返回1成功,0失敗

*/

int

Statistic(char*

pt,int

*pNum,int

*pNumSpace,int

*pNumAll)

{

char*

pcur=pt;

*pNum=*pNumSpace=*pNumAll=0;

while(*pcur!='\0')

{

if((*pcur>0x40&&*pcur<0x5B)||(*pcur>0x60&&*pcur<0x7B))*pNum++;

if(*pcur==0x20)*pNumSpace++;

pNumAll++;

pcur++;

}

return

1;

}

/*

統計某壹字符串*p在文章*pt中出現得次數,

返回次數

*/

int

GetTime(char*

pt,char*

p)

{

char

*a=pt,*temp=a,*b=p;

int

num,isok=0;

while(*a!='\0')

{

while(*b!='\0')

{

temp=a;

b=p;

if(*(temp++)==*(b++))

isok=1;

else

isok=0;

}

if(isok)num++;

a++;

}

return

num;

}

/*

刪除*pt中第壹次出現的字串*p

成功返回1,否則0

*/

int

DelString(*pt,*p)

{

char

*a=pt,*temp=a,*b=p;

int

num,isok=0;

while(*a!='\0')

{

temp=a;

b=p;

while(*b!='\0')

{

if(*(temp++)==*(b++))

isok=1;

else

isok=0;;

}

if(isok)

{

while(*temp!='\0'&&(*(a++)=*(temp++))

*a='\0';

return

1;

}

a++;

}

return

0;

}

  • 上一篇:軟件開發流程分工
  • 下一篇:國1國2國3國4國5標識什麽意思
  • copyright 2024編程學習大全網