<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # C 程序:查找字符串中字符的頻率 > 原文: [https://www.programiz.com/c-programming/examples/frequency-character](https://www.programiz.com/c-programming/examples/frequency-character) #### 在此示例中,您將學習查找字符串中字符的頻率。 要理解此示例,您應該了解以下 [C 編程](/c-programming "C tutorial")主題: * [C 數組](/c-programming/c-arrays) * [C 編程字符串](/c-programming/c-strings) * * * ## 找出字符的頻率 ```c #include <stdio.h> int main() { char str[1000], ch; int count = 0; printf("Enter a string: "); fgets(str, sizeof(str), stdin); printf("Enter a character to find its frequency: "); scanf("%c", &ch); for (int i = 0; str[i] != '\0'; ++i) { if (ch == str[i]) ++count; } printf("Frequency of %c = %d", ch, count); return 0; } ``` **輸出** ```c Enter a string: This website is awesome. Enter a character to find its frequency: e Frequency of e = 4 ``` * * * 在該程序中,用戶輸入的字符串存儲在`str`中。 然后,要求用戶輸入要找到其頻率的字符。 它存儲在變量`ch`中。 然后,使用`for`循環迭代字符串的字符。 在每次迭代中,如果字符串中的字符等于`ch`,則`count`增加 1。 最后,打印存儲在`count`變量中的頻率。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看