編寫函式,統計給定字串中各個字母出現的次數,不區分大小寫

2021-04-01 06:14:47 字數 3087 閱讀 6861

1樓:苒夏安

比如對hello,tom 進行統計

void count_chars(char s,int **t)}main()

;int i;

count_chars(s,**ts);

for(i=0;i<26;i++)}

編寫函式,統計給定字串中各個字母出現的次數,不區分大小寫。

2樓:苒夏安

比如對hello,tom 進行統計

void count_chars(char s,int **t)}main()

;int i;

count_chars(s,**ts);

for(i=0;i<26;i++)}

編寫函式實現統計一個字串中每個小寫字母出現的次數。

3樓:用著追她

1、檔案--》新建--》專案。

2、選擇為:控制檯應用程式--》命名:統計一個字串中每個小寫字母出現的次數--》確定。

3、確定後系統生成的**。

4、先寫一個字串用於測試。

5、使用dictionary集合然後迴圈判斷測試**。

6、程式執行測試成功後顯示每種字母出現的次數。

4樓:bbk臨兵

#include

#define n 100

void count(char str,int times)   //統計小寫

字元出現次數

}int main()

return 0;

}ps:唐同是誰^^

編寫一個函式,它的功能是統計一個字串中所有字母的出現次數,字母不區分大小寫

5樓:匿名使用者

執行了一遍, 正確, 只是不區分大小字母.

6樓:

能執行,但是有些細節不是太好。

比如,a這個陣列的長度,^_^。

vb 輸入一個字串,編寫程式統計其中每個字母出現的次數 (不區分字母大小寫)

7樓:聽不清啊

private sub ***mand1_click()

dim a(26) as integer

s = text1.text

for i = 1 to len(s)

b = asc(mid(s, i, 1))

if b >= 97 and b <= 97 + 25 then b = b - 32

if b >= 65 and b <= 65 + 25 then a(b - 64) = a(b - 64) + 1

next i

text2.text = ""

for i = 1 to 26

text2.text = text2.text & chr(64 + i) & "=" & a(i) & "  "

if i mod 7 = 0 then text2.text = text2.text & vbcrlf

next i

end sub

8樓:匿名使用者

dim abc(65 to 90) as integerdim ab as integer

for i = 1 to len(text1) '

ab = asc(ucase(mid(text1, i, 1)))if ab > 64 and ab < 91 then abc(ab) = abc(ab) + 1 '是字母a-z

next i

for j = 65 to 90

text2 = text2 & chr(j) & "=" & abc(j) & chr(9)

next j

用c語言編寫輸入一字串,統計字串中各個字母出現的次數(區分大小寫)

9樓:匿名使用者

#include "stdio.h"

#define n 100

int main() ,down[26]=;

for(i=0;i!=0;i++)

}printf("the result is as follows:\n");

for(i=0;i<26;i++)

return 0;}

10樓:匿名使用者

#include

void main()

for ( i=0;i<256;i++ ) if ( a[i] ) printf("字元%c出現次數%d\n",i,a[i]);}

11樓:聽不清啊

#include

int main()

;char ch;

dowhile(ch!='\n');

for(ch='a';ch<='z';ch++)if(a[ch])cout<

c語言程式設計:輸入一串英文字母,統計每個字母(不區分大小寫)出現的次數

12樓:匿名使用者

#include

#include

using namespace std;

int main()

else

break;

}cout<<"字串的數量為:"

13樓:wsp竹木

#include

void main()

; //陣列s用來統計每個小寫字母的個數printf("please input a string:\n");

scanf("%c",&ch);

while(ch!='\n') //輸入一行字元,以回車鍵結束

printf("\n");

for(i=0;i<26;i++)

if(s[i]) //只輸出輸入過的字母統計printf("%c:%d\n",(char)(i+'a'),s[i]);

//(char)(i+'a')用強制型別轉換,輸出對應字母}

c 程式設計 編寫字串反轉函式,C 程式設計 編寫字串反轉函式mystrrev

應用c 的string類物件實現。為體現一般性,物件中就允許空格出現 自定義逆序函式形參應使用引用型別,以便永久性改變對實參物件的操作。舉例 如下 include stdafx.h if the vc 6.0,with this line.include include using namespac...

C語言求助 請編寫字串壓縮程式,將字串中連續出席的重複字母進行壓縮,並輸出壓縮後的字串

用下面的 給你提供個思路。這 連續字元不得超過9個 include stdio.h void main void else a k a i a k 0 printf the result s.n a include int main scanf s a char result 1000 int i ...

c語言輸入字串,將該字串中從第m個字元開始的全部字元複製到另字串

這樣 include include int main void copystr char char int int m char str1 20 str2 20 printf input string gets str1 printf which character that begin to c...