c語言輸入一串字符統(tǒng)計個數(shù) C語言編寫函數(shù),統(tǒng)計字符串中數(shù)字字符的個數(shù)?
C語言編寫函數(shù),統(tǒng)計字符串中數(shù)字字符的個數(shù)?#包括和限制。H>#包含<string。H>main(){int i,j=0,K char a[1000]//根據(jù)實際情況自行調整長度。Prin
C語言編寫函數(shù),統(tǒng)計字符串中數(shù)字字符的個數(shù)?
#包括和限制。H>#包含<string。H>main(){int i,j=0,K char a[1000]//根據(jù)實際情況自行調整長度。Printf(“請輸入字符串:n”)獲?。╝)k=strlen(a)for(I=0I<ki)if(“0”<=a[I]<=“9”)J Printf(“此字符串中有%d個數(shù)字字符!N“,J)}
~]//計算字符串#include”stdio中相同字符的個數(shù)。H“#include”字符串。H “int count ”str “same(char*p,char ch)int main(){int same ”Chchar a[100]char cprintf(“please input string:”)get(a)printf(“please input repeated characters to be counted:”)C=getchar()same “ch=count ”str “same(a,C)printf(“字符串中的字符%C重復%d次n”,C,same “ch)return 0}int count ”str_相同的(char*P,char CH){char*q=pinm=0while(*q!=“0”{if(CH==*q)mq}return m}也可以將函數(shù)寫入頭文件,復制到include文件夾,然后通過頭文件加載。