0 like 0 dislike
5.9k views
 

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

 

輸入範例1:

12321

輸出範例1:

12321 is a palindrome

輸入範例2:

apple

輸出範例2:

apple is not a palindrome

[Normal] Coding (C) - asked in 2016-1 程式設計(一)AC
ID: 20482 - Available when: Unlimited - Due to: Unlimited

reshown by | 5.9k views
0 0
Called for Help

31 Answers

0 like 0 dislike
Hidden content!
#include * * *** * *** *
* * * * * * * *



 int ** * * *s) {
** * **** ** * *** i, len;


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


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


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

}


**** main() {
* * * ** s[10];


* * * * * * {
* * *** * * * * * **


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

 }
answered by (-120 points)
0 like 0 dislike
Hidden content!
#include *** ** ***** *
*** * * * ** * *



 int * * * * *s) {
* ***** * *** * *** i, len;


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


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


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

}


* *** main() {
*** * * *** s[100];


* * * * * {
* ** *** * * ** * * *


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

 }
answered by (-120 points)
0 like 0 dislike
Hidden content!
* * * *****
* **** ** *

int *

{

int * *


* * ** * * *



for * ******* * * * ***** ** ***** // * ***



if * * * *** * * is a ** *
* **** ** * is not a * ** * **




* * 0 ;

}
answered by (-120 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>

#include <string.h>



int main()

{
* ** ** ** ** *********** * a[100],b[100];
******* **** * ** * * l,i=0,j,n=0;
* *** *** ** * * ***** * *** **
** * * * ** ** * ** = strlen(a);
* * ** ** * ** * * *** ** * * ***
* ** **** ** * * * **
** * ****** * * * ** * * *** ** ** * * **
** * ** *** * *** ** * * *** * **** * * * **** = i+1;
* *** ** * ** * ** *
**** * ** ** * ** ** * * ** ***
* * ** ***** * *****
* * ** ** * *** * * **** * * *
** **** *** * **********
* * * ** * *** * **
* * ** ** ***** ** ****** ** *****
**** * ** *********
** * * * * ** ** ***
* *** * * * ** * * ***** **
** ** **** * * * *****
** * *** ** * * * **** *
** * * ** * * * * * * ** * *** * is a palindrome\n",a);
**** ******** *** * * * if(n!=l)
****** ** ** * ** **** ****** * is not a palindrome\n",a);
*** ** ** * ** * * * * 0;

}
answered by (-85 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>
* * * * ***** * **
* * *** * * * *** * **

#include <ctype.h>

int main(void)

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

}
answered by (-162 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>
* *** * * ****
* *** * **** * *

int main(void)

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

}
answered by (-124 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>
** ** * ***
**** * ** * * **

#include <ctype.h>

int main(void)

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

}
answered by (-162 points)
0 like 0 dislike
Hidden content!
** *
** * * * * *
* ** * ** *

#include <ctype.h>

int main(void)

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

}
answered by (-124 points)
0 like 0 dislike
Hidden content!
**** * * *
*** * * ****
* * *** * * *

#include <ctype.h>

int main(void)

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

}
answered by (-124 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>
** * ** * *
* * ** * * **

#include <ctype.h>

int main(void)

{
** **** * * ** *** i,len;
*** * * * * ** * s[100];
** * ** * ****** ** * * *
**** ** * * * ** * * * *
** * * *** * * *** * * * *
*** ** * *** **
*** * * ** * **** ** ** * ** ** * * ***** != s[len-i-1])
** * ** *** * * ** ** * * * * * * * *
*** * * *** * ** ** * ** * * * * *** * ** ** **** **** *** ** *** 不是回文",s);
* ** * * * * * * *** * * * **** *** * * * *** * ** ** * ***
* * * ** * * **** **** ** * ** * * ** **** * *    
** ** *** * * * *
* **** * ********* * (i>=len/2)  
* * * ** * * * ***** * **** ** * * * 是回文",s);

}
answered by (-124 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:104.23.243.109
©2016-2026

Related questions

0 like 0 dislike
7 answers
[Normal] Coding (C) - asked Jan 5, 2017 in 2016-1 程式設計(一)AC by 林佳慧 (-85 points)
ID: 20976 - Available when: Unlimited - Due to: Unlimited
| 1.7k views
0 like 0 dislike
24 answers
asked Dec 7, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points) | 4.5k views
0 like 0 dislike
3 answers
[Normal] Coding (C) - asked Jan 5, 2017 in 2016-1 程式設計(一)AC
ID: 20997 - Available when: Unlimited - Due to: Unlimited
| 1.3k views
0 like 0 dislike
3 answers
[Normal] Coding (C) - asked Jan 3, 2017 in 2016-1 程式設計(一)AC by 410425014 (-162 points)
ID: 20514 - Available when: Unlimited - Due to: Unlimited
| 1.3k views
0 like 0 dislike
5 answers
[Normal] Coding (C) - asked Dec 27, 2016 in 2016-1 程式設計(一)AC by 410342026 (-105 points)
ID: 20135 - Available when: Unlimited - Due to: Unlimited
| 2.2k views
12,783 questions
183,442 answers
172,219 comments
4,824 users