<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://beginnersbook.com/2015/02/c-program-to-check-if-a-number-is-palindrome-or-not/](https://beginnersbook.com/2015/02/c-program-to-check-if-a-number-is-palindrome-or-not/) 如果我們反轉數字,它也保持不變,該數字也稱為回文數。例如,12321 是回文數,因為如果我們反轉它的數字它仍然是相同的。在本文中,我們共享了兩個 C 程序來檢查輸入數字是否為回文數。 1)使用`while`循環 2)使用遞歸。 #### 程序 1:使用`while`循環檢查回文 ```c /* Program to check if a number is palindrome or not * using while loop */ #include <stdio.h> int main() { int num, reverse_num=0, remainder,temp; printf("Enter an integer: "); scanf("%d", &num); /* Here we are generating a new number (reverse_num) * by reversing the digits of original input number */ temp=num; while(temp!=0) { remainder=temp%10; reverse_num=reverse_num*10+remainder; temp/=10; } /* If the original input number (num) is equal to * to its reverse (reverse_num) then its palindrome * else it is not. */ if(reverse_num==num) printf("%d is a palindrome number",num); else printf("%d is not a palindrome number",num); return 0; } ``` **輸出:** ![checking_palindrome_number_output](https://img.kancloud.cn/2b/38/2b38b6ef4750a8a976a1f640b3e8b43a_533x236.jpg) #### 程序 2:使用遞歸檢查回文 ```c #include<stdio.h> int check_palindrome(int num){ static int reverse_num=0,rem; if(num!=0){ rem=num%10; reverse_num=reverse_num*10+rem; check_palindrome(num/10); } return reverse_num; } int main(){ int num, reverse_num; printf("Enter a number: "); scanf("%d",&num); reverse_num = check_palindrome(num); if(num==reverse_num) printf("%d is a palindrome number",num); else printf("%d is not a palindrome number",num); return 0; } ``` **輸出:** ![palindrome_using_recursion](https://img.kancloud.cn/66/0c/660c6caf9d20fb852cd324e5acb88643_573x284.jpg)
                  <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>

                              哎呀哎呀视频在线观看