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

輸入範例1:

12321

輸出範例1:

12321 is a palindrome

輸入範例2:

apple

輸出範例2:

apple is not a palindrome
[Exercise] Coding (C) - asked in 2016-1 程式設計(一)AC by (18k points)
Available when: Unlimited - Due to: Unlimited

reshown by | 272 views

43 Answers

0 like 0 dislike
Hidden content!
* * *** ** * * * ** **
** * ********



int is_palindrome(char *s)

{
** *** * ***** a, k;



  k = strlen(s);


* ** * ** = 0;a <(k /2);a++)
* * * ***
** *** ** * ********** *** * ** (s[a] != s[k-a-1])
*** ** ** * ** ** ** * ***** * *** 0;
* *** * *****


** * * * * ** >= k/2)
* ** **** * * **** * * 1;
****** * ** ** * *
** *** **** * ** 0;

}

int main(void)

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


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

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

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



int is_palindrome(char *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_palindrome(s))
* ***** ** ** * * * * * * * * ** ** * * *** ** * is a * ** ** ******* s);
** ** * ** ** ** **** ** * *** *
** **** * * ** *** ** ** * * * * **** ** ** **** * * * ** * is not a * ** * ** s);
* ** * ** * * ** *

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



int is_palindrome(char *s)

{
* * * * ** * ** a, k;


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


*** * *** ** *** = 0;a <(k /2);a++)
* * * *
********* * * ** * * * (s[a] != s[k-a-1])
* * * *** *** * **** ** *** **** ** * * 0;
** * * * *


** ** * * **** >= k/2)
*** * * * * **** * *** 1;
* ** * ** *
** ***** * ** * * 0;

}

int main(void)

{
* * ** * * ** s[300];


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


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



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

#include * * ** ** *



int is_palindrome(char *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_palindrome(s))
* ***** * * * ****** * **** ** * ***** ** * ***** ** **** * ** ****** is a *** * **** s);
** * * * ** * ** * ** * ** **** ***** *
** * ** ****** * ** * * ** * ** ** * ** **** ** ** is not a * * *** * s);
* * *** ** * *

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

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



int is_palindrome(char *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_palindrome(s))
** * ** * * *** * * ** ** * * * * * * ******* **** * *** is a palindrome", s);
***** ** ** *** ** ** * * * ** *
* * ** * * * *** *** ****** * * * * * ** is not a ** *** **** s);
* * **** ** ****

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



int main()



{

int * ** ***



for ** * * **


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



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

else if ** ** *
*** * ** ** * * ** * *** is not a *** * * * *** * ***
answered by (54 points)
0 like 0 dislike
Hidden content!
#include <stdio.h>

#include <stdlib.h>



int main()

{
*** *** ** ******* ** * * **** a[100],b[100];
***** ** ** * ** * * ** * i,j,k=0,l=0;
* ** * ** * * * *** *** **
*** * * * ** * ** * ***
*** * ** * ** * ** **
** * ** * *** ** *** * * ** *

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

    }
* * ** *** *** ** *** *
** ** *** * * *** ** ** * * ******

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

    }
** * * * **** ***** *
**** ***** * ** ***** * ** * * * * * is a palindrome",a);
* *** * * ** ** ******* ** if(l!=j)
* * * ***** * ** * * ** ** * ***** * * * *** * * is not a palindrome",a);
* * * * ** * *** * *** 0;

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

#include <stdlib.h>



int main()

{
** ** *** ** * * a[100],b[100];
** ******* ** ** ** * i,j,k=0,l=0;
* * ** * ** * * ***
* ** * * ** * * * * **** *
** * * * * * ****
* ***** *** **** * * ** ** **

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

    }
*** * *** * *** * ** **
** *** **** *** * * * *** * * *** *****

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

    }
** * * **** *** * **
** ***** * ****** * ** * * ** * ** **** * * *** * * is a palindrome",a);
** *** * ** ** * * * ** ** if(l!=j)
** * ** * ** * *** ** ** *** * * * * ** ** ** * * ** ** is not a palindrome",a);
**** *** **** ** *** ** *** 0;

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

#include <stdlib.h>



int main()

{
*** ** *** **** * ***** * a[100],b[100];
* ** ** ** *** ***** * * i,j,k=0,l=0;
** * **** ** * ** * ** ** ** **
***** ** *** * * *********
* * * ** ** **
** *** ** * * * ******* * **

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

    }
** ** ** * * ***** ** * *****
* ** * ***** ** * *** *** *

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

    }
** * ** ** * ***** * **
* ** * ***** ** *** * * * * * ** * ** * *** * is a palindrome",b);
* * ** ** ** ** *** **** * if(l!=j)
** * *** * **** * * *** * * ** ** * * * is not a palindrome",a);
****** ** * **** *** **** 0;

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

# ** * ** *



int ***

{
* * ***

int i;
** * ******** * * *
** * * * *
** * * is a * *** ** *

else
* ** ** * is not a * * * **


* 0;
* * }
answered by (-122 points)
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:108.162.219.194
©2016-2020

Related questions

0 like 0 dislike
3 answers
[Exercise] Essay (Open question) - asked Jan 5, 2017 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 56 views
0 like 0 dislike
144 answers
[Exercise] Coding (C) - asked Jan 5, 2017 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 786 views
0 like 0 dislike
28 answers
[Exercise] Coding (C) - asked Jan 5, 2017 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 175 views
0 like 0 dislike
39 answers
[Exercise] Coding (C) - asked Jan 5, 2017 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 216 views
0 like 0 dislike
16 answers
[Exercise] Essay (Open question) - asked Jan 5, 2017 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 128 views
10,728 questions
119,707 answers
110,434 comments
3,802 users