0 喜歡 0 不喜歡
4.8k 瀏覽
 

請設計一個程式,使用者會輸入一個字串,請判斷該字串是否為回文(palindrome)。

 

輸入範例1:

12321

輸出範例1:

12321 is a palindrome

輸入範例2:

apple

輸出範例2:

apple is not a palindrome

[正常] Coding (C) - 最新提問 分類:2016-1 程式設計(一)AC |
ID: 20482 - 從幾時開始: 無限制 - 到幾時結束: 無限制

重新顯示 用戶: | 4.8k 瀏覽
0 0
Called for Help

31 個回答

0 喜歡 0 不喜歡
已採納
內容已隱藏
* ** ***** * ** ****
* * * *** ***
** ** * *** * *

#include <ctype.h>

int main(void)

{
*** * ** ** * i,len;
***** * * * ** * * ** s[100];
** ** ** ** * *
** ****** * ** ** ** ****
* * ***** ***** ** * = 0;i < len / 2;i++)
** ** ** ** * ******* *
* ** * * * *** * ***** * ** ** * *** * != s[len-i-1])
***** ***** * * ** * ** * ** ** ***
*** * * *** *** ** ** * * ** ** *** **** ** *** ** * * * ** *** * is not a palindrome",s);
*** *** * * *** *** ** ** * * ** * *** ** * * * ***** * * * *
* * * * * ** * ** * * * * * *** * * * * * ** ** * ****
* * * * * ** * * ** *
* * * * ** (i >= len / 2)  
* ** * * * **** ** * * * is a palindrome",s);

}
最新回答 用戶: (-124 分)
0 喜歡 0 不喜歡
內容已隱藏
最新回答 用戶: (-276 分)
0 喜歡 0 不喜歡
內容已隱藏
* ** * *

* ****** ***

* * ** * * * * * ***



int main (void)

{ ***** *** * * *
* * * ** * ** ** * * *** * ** * a,b,c,d,i,k,j;

**** ** *** ** ** ** ** * s[99],z[a-1];



***** * * ** ***** *** * **** * * **

* ***** * ** *** * * **** * **

* * ** * * * **** *****
** * * *** * ** * **** (s[a-1]==s[0])

** * * *** ** * *** ** *** ** ("%s is a palindrome",s);

* * * *** **** ** * * ** ***

* * * * * * * * * * * * ("%s is not a * * * *

** * * ** * ** * * * * * *
* ** *** ***** ****** * *


* *** ** ** * * ** * ** * 0;

}
最新回答 用戶: (-122 分)
0 喜歡 0 不喜歡
內容已隱藏
* * * *** *

* ****** **

** * ** *** * *

*** ** * * * *******



int main ()

{ ** * ** * * * ** ***
* ***** * * * ** *** a;

** ************ **** * ** s[99];



* * ** * * * ** * *** *** *******

*** * * * * *** **

* *** ** * * *** * ***
***** * ** * ** * * (s[a-1]==s[0])

**** * *** * * * * *** *** ("%s is a palindrome",s);

* * ** ******** ** **** ***

* * *** ** * *** ****** * * ("%s is not a palindrome",s);

** **** * *** ** *
**** ** ** * **** *** *


*** * * ** * * * ** 0;

}
最新回答 用戶: (-102 分)
0 喜歡 0 不喜歡
內容已隱藏
#include *** * ** *

#include * * * **


***** * ** ** *s)

 {
* * *** ** **** ** i, len;


*** * * ** = strlen(s);


****** ****** ** * = 0; i < (len /2); i++) {
*** * * *** * * * * * * (s[i] != s[len-i-1])
* * * ****** *** * * *** *** ** * ****** *** 0;
* ** ** ** * * *


* *** * * * * *** (i >= len/2)
* ** ** **** * ** * **** ** ** 1;
** * * * * ***
***** ** * * * * * *** ** 0;

 }



 int main()

 {
* ** **** ** ** s[256];


*** ** * ** * *

* ** ** * * * *
* **** *** ** ** ***** * * ***** *
** **** * *** * ** ** * ** * * * * ***
* *** * ** * ***** **** **** *** * ***** * ** * * * is a * * s);
* * * * *** ** **** * **
* *** ** * *** * ***** * * * * ** ** *** ** is not a * ** ** s);
* * ** *** * *

 }
最新回答 用戶: (-143 分)
0 喜歡 0 不喜歡
內容已隱藏
#include  <stdio.h>

#include  <assert.h>

#include  <stdlib.h>

#include  <string.h>



int  main(void)

{
*** * **** ** * ** ** i,j=0,flg=0;
** * * * **** * * *** * a[10],b[10];
** * *** * * * ***** * * ***** *******
* * ***** *** * *** ** ******
*** ** ** **** * ** * *** *
**** ** *** * **** **** ** *** * -1;i--){
* * * ** ** ** ** * * **** ***** * ***
** * ******** ** * * *** ****** * * * ** ** **** * **** ***
****** * ***** * * * *** * * ****** * * ** ** * * *** * * * ** *
** * ** * ** ** ** ********* ****
* * * * ** * * ****** *
**** ** **** * ** * * * * *** ** *
* ** * *** * ******* ***** **** * ** * ** * **
** * *** **** ** **** * *** * *** ** * ** **** ***** ** * ** * * * *
* * *** **** * ** * * * ***** ***** *** ** *** ** ** * * ** * *** * * ** * * *
* * * ** **** * ** ** * * *** * * * * *** *** * * ***** **** * ** *** * ** * ** **
** * * * ** ****** ** ***** ** *** * **** * ** * * * *** * * *
** ** * *** * * * * * * * ** * * * ** ** **
*** * * * * * **

    
** * *** * ** *** *** * **
** **** ** ** ** ** * * ** ** ** * * * *** is a palindrome",a);

    }
** *** * *** * * **** **
*** * * ** ** * * **** * * *** * * * * ** ** *** ******** *** is not a palindrome",a);

    }
* ** * ** ** **** *  0;

}
最新回答 用戶: (-158 分)
0 喜歡 0 不喜歡
內容已隱藏
* *** * ** **
** * ** ** **** * * **
* ** * * * ***** ***
*** * * * ******



int main (void)

{ * * *****
* * * ** ******** * a,b,c,d,i,k,j;
* * * ***** * ** * *** s[99],z[a-1];


* * ** * * ** * ***** ** * **** * ** *
* ** * * ** * ** *** * ** * ***
* ** * ** **
*** ** * * ** *** (s[a-1]==s[0])
* * *** ** **** * * * ******* ("%s is a ***** ** * ** *
* * * ***** **** * *
* * * ** * ** ** *** * *** ("%s is not a *** * * * * **
* ***** ** ** *** ** ***
* ** ** * *** ** * * *



    return 0;

}
最新回答 用戶: (-136 分)
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>

#include * ** * *** ***



int main(void)

{
* ** **** * ** * * s[100];
*** ** * * *** * * ** i, j, n;
*** ** *** * ** ** * * *
** * ** ** * ***
** *** * * * * * * ** * **
* * * ** * ** *** * * * ** ****** * **** * *
** *** * * * * * ****** *** * ** break;
* * *** *** **** * * * *** ** **
* ** *** **** * * * ** * * * ** * * * * * * ** is a palindrome\n", s);
**** *** ** * * * *****
** ** *** ** **** *** * ***** **** * * * * * is not a palindrome\n", s);
** * ** * * * * *** **** ** 0;

}
最新回答 用戶: (-100 分)
0 喜歡 0 不喜歡
內容已隱藏
#include <stdio.h>

#include ** *

 

int is_palindrome(char *s) {
** * ** * ***** ** * i, b;
**** **** * *
** ** * **** * = strlen(s);
** *** ** * *
* *** ** ******* = 0; i < (b /2); i++) {
** *** ** ** ** ** ** (s[i] != s[b-i-1])
* * **** ** *** * ********* ** *** ** 0;
**** ** * **** *
** ** * ** *** (i >= b/2)
*** ** * * * * ** ***** * 1;
*** * ***** *** *
* * * ** * * ** * ** * * * 0;

}

int main()

{
* **** ********* * s[256];
** * ** *** *** **
* * * * * * ** * *

*** *** ******
* ** * * * ******* **
* **** ** * ** * ** *** * * *
** *** *** ****** ** *** * (is_palindrome(s))
**** *** * * * ** ******* ***** *** * **** * ** ** ** * * *** is a ** ** ** s);
* ** * ****** * * * * * *
** * *** *** ** * *** ** * **** * * * *** ** ** * * is not a ** *** * ** s);
* *** ** ** ** *** *** ** 0;
* **** ** ** * ****

}
最新回答 用戶: (-100 分)
0 喜歡 0 不喜歡
內容已隱藏
#include * **** * *

#include ** ** * *

 

int is_palindrome(char *s) {
** * **** * * ** i, b;
*** ** ** * *** * **
*** * * * ** = strlen(s);
** ** ** *******
* * * * ** ** = 0; i < (b /2); i++) {
* ***** * * * ** ** (s[i] != s[b-i-1])
* * ** ** ***** *** ** ** * * ***** 0;
* ** **** * *
* ***** ** * * (i >= b/2)
* ** ** ** ** ** * 1;
***** * * * ** *
** * * * ***** * * * 0;

}

int main()

{
***** ****** * * ** * s[256];
** *** ** * * *
* * **** * ** * ****** *

******* * ***
* ** * * ** *** ** * * ***
* **** * * ** ***** ***** *****
** **** * * * ** ** ** * * (is_palindrome(s))
**** * * ***** ** *** ** ** ** ** * * * *** ** ** is a palindrome\n", s);
*** * * ** * * ***** ***
* *** *** * *** *** * * ** * * ** * ** * ** is not a * **** *** ** s);
* * * * * * **

}
最新回答 用戶: (-100 分)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.130.92
©2016-2025

相關問題

0 喜歡 0 不喜歡
7 回答
[正常] Coding (C) - 最新提問 1月 5, 2017 分類:2016-1 程式設計(一)AC | 用戶: 林佳慧 (-85 分)
ID: 20976 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 1.4k 瀏覽
0 喜歡 0 不喜歡
24 回答
最新提問 12月 7, 2016 分類:2016-1 程式設計(一)AC | 用戶: Shun-Po (18k 分) | 3.6k 瀏覽
0 喜歡 0 不喜歡
3 回答
[正常] Coding (C) - 最新提問 1月 5, 2017 分類:2016-1 程式設計(一)AC |
ID: 20997 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 1.1k 瀏覽
0 喜歡 0 不喜歡
3 回答
[正常] Coding (C) - 最新提問 1月 3, 2017 分類:2016-1 程式設計(一)AC | 用戶: 410425014 (-162 分)
ID: 20514 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 1.1k 瀏覽
0 喜歡 0 不喜歡
5 回答
[正常] Coding (C) - 最新提問 12月 27, 2016 分類:2016-1 程式設計(一)AC | 用戶: 410342026 (-105 分)
ID: 20135 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 1.8k 瀏覽
12,783 問題
183,442 回答
172,219 留言
4,824 用戶