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)
ID: 20980 - Available when: Unlimited - Due to: Unlimited

reshown by | 532 views

43 Answers

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





int * * **
** * * *

** * * * * char a[100];
* * ** *

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

** * * * int ** * **
** * *****

****** * * len = * * *
** ** * *****

** * * * * for (i = 0;i * * *** *
**** * * * * * ***

* * * ** *** * * ** if (a[i] != * **
** *** ***** * ** {
* * ** * ** * * * ***

* * *** ** * * *** j = 1;
*** ******* ** ** * ** *

**** ** *** ** ** break;
** *** * *** ***** *** * * *

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

******* * * * *** * ** * else if (a[i] == * * *
** ** * *** *** ** ***

* * * * **** * * * * ** j = 0;
** * * * **

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

* **** * ** *** if (j == 1)
* * * ** ****

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

** * * * else if (j == 0)
*** **

** * *** * * ** ** is a * ***** ***


* ***** ***** * return 0;
*** ** **

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

#include<stdlib.h>



int is_palindrom(char*s)

{
** ***** *** ** * * ** i,len;
** * *** * *** = strlen(s);
* ** ***** * ** ***** ** ** ** * **
****** *** * ** * *
* * * *** * ** *** * ** ** * ** **** ** *******
*** ** * * * ** ** * ** * ** * **** * * * *** * * * 0;

    }
* **** ****** * ** >= len/2)
** * ** * **** ****** * * * * ** * *** * 1;
*** ** * ** ** * * * *** **
* ****** ** ** *** *** * * * * *** ** * *** * 0;

}

int main()

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


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


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

    }

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

#include * * *



int main(void)

{
* * **** * * * * *** ** s[1000];
* * * * * * **** i, j, n;
* * **** * ******* ** * **


** * * *** *** * ***
** * ** * * * *** *
* **** * * ** *** **** ** ***** break;
** *** *** ** ****** * **** *
* * * *** * * * * * * * * * ** *** * * ** * * * * * * * is a palindrome", s);
* *** ****** ** * * * * *******
* * *** * * **** ** * * ** ** * * * * * *** ** is not a palindrome", s);
* *** * * *** ** ** ** 0;

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



int main(){
* * * * **** * * * a[80];
**** ** * * ** *** ** ** l, i, j = 0;
* ** *** * * ** * *** * * * *** * * **** a);


* * * ***** * ***** * ** *** * * l);
*** ****** ** *** ** = 0; i < strlen(a) / 2; i++){
* **** * * * ** * * ** **** ** * ***** ** * *** == a[strlen(a)-1-i])
*** * * ** * * * * * **** ** ** * ** ** * ** ** * *** ***** **** *
**** ** **** *** * * *
* * ** * ** * ****** ** == strlen(a)/2 )
* *** *** * * ** ** * *** * ****** * **** * * * *** is a palindrome", a);
** * ** * * ** * *** *
** * ** *** *** * *** ** **** ** * *** *** *** * * * * is not a palindrome", a);
* **** * * ** ** * **** * * **** * j);

return 0;

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

#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);

}
answered by (-124 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!
#include<stdio.h>
* * * ******** *
* * * ** * * **
* *** ** *** * *



int main()

{

* * * * **** *** *** * a;
*** *** *** * *** ** * ** * s[500] ;
* ** ** ** * * * ** * * * * ** ** *
* * *** ** * ** ** *****
* **** * ** * *** *
****** ** * *** ** * * ** *
** * * * ** ********* * **** * * * * * * * is a palindrome",s);
**** * *** ** * ***
** * ** ** ** ** * ** *** * ** ** * * * **** *** * * * ** is not a palindrome",s);
*** ******* ** *** * 0;

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

#include  <assert.h>

#include  <stdlib.h>

#include  <string.h>



int  main()

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

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

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

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


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

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

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

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

int main()

{
* *** *** * int a;
***** * ** **** * char s[99];
** * * * **

* ** *** * scanf ** * **** * *
*** * *** *** * * * *
* *** ** **

*** * * * *** if ** **
**** * *** * printf ****** is a **** **** **
** * * ** else
** * * * ***** *** **** ** *** is not a * ** * * * *
** ** *

** * * *** return 0;

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



int main()

{

* * * * **** * *** * ** a;
* *** * ** * * * * * s[500] ;
** ** * *** * *** ** * *****
* ** * ** ** * * ** *
* * *** * * ** * * *** **
* * ** * * * ** ** *** *** **
*** ** * * * * *** * * ** ** * * *** ***** *** *** is a palindrome",s);
* * * * ***** ** *
* * * *** * *** ***** **** *** * * ** ** *** * * is not a palindrome",s);
** ** ***** **** * ** ** 0;

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

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)
ID: 20995 - Available when: Unlimited - Due to: Unlimited
| 116 views
0 like 0 dislike
144 answers
[Exercise] Coding (C) - asked Jan 5, 2017 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 20993 - Available when: Unlimited - Due to: Unlimited
| 1.6k views
0 like 0 dislike
28 answers
[Exercise] Coding (C) - asked Jan 5, 2017 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 20984 - Available when: Unlimited - Due to: Unlimited
| 450 views
0 like 0 dislike
39 answers
[Exercise] Coding (C) - asked Jan 5, 2017 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 20978 - Available when: Unlimited - Due to: Unlimited
| 509 views
0 like 0 dislike
16 answers
[Exercise] Essay (Open question) - asked Jan 5, 2017 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 20974 - Available when: Unlimited - Due to: Unlimited
| 274 views
12,482 questions
174,240 answers
168,082 comments
4,649 users