0 like 0 dislike
8.6k views
請設計一個程式,使用者會輸入一個字串,請判斷該字串是否為回文(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 | 8.6k views

43 Answers

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[1000],b[1000];
* ****** ** ** * **** 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<string.h>

int main(void)

{


* **** *** ** * ******* i[100]={0},j[100]={0};
* **** ** * ** * * l,a,temp,b,temp2;

    
** * * ** * * * * * *** *** * * * *
* ** ** *** *** * *** *****
** *** * * * * *** * ** **** ** * *
*** * *** * * *****
** ** * * * * * ** * * ** * * * **** * * *
* ** * * *** *** ** * *** *** ** ** *
*** *** ** * **** * * ** **
* ** ** **** ** * * ** * * *
* **** *** ** ***** *
* ** ** * * ** **** * * **** * * *** *
** **** ** ** * * ***** * *** * *** ********
* * * * ** * *** *** *** ** * ** * *** *
* *** *** * ** *
* **** * * * * **** **** *
* ***** ** **** * * ***** * * * is a palindrome",i);
* *** ****** ***** ** if(i[100]!=j[100])
*** **** *** *** * ** ** * * is not a palindrome",i);
** * * * * * **
** ** ** * * ** * * 0;

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

#include **** **** *

#include ** ** ** **



int main(int argc, char *argv)

{
* ** * * * *** * ** * * a[100];
* ** * * **** ** ** ** b[100];


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


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

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

#include <stdlib.h>

#include <string.h>

int main ()

{
*** *** **** *** **** ** ** ** i,l;
** * * * ** ******* * * str[100];


** * ** * **** * ** * *** * *** * * * ** * *
* **** ** * * ** ** *
** * *** * * ***** * ** **** (i=0 ;i<l/2 ;i++)
* **** ** * * ** **
**** * **** * * * * * **** *** * * * (str[i] != str[l-i-1])
* * ** * * **** ** * ** * * * ** * ****** ** ***** * ** ** **
* * * ******* ** ** ****** *********** * * * * * * * ****** ** * * **** * * ("%s is not a ** *** * ** **
*** ** * * * * ****** * * * * * * * * * * * **** ** * * * *** ***** * * ** ** *
*** **** * **** **** *** * * * *** * * ***** ****** ** *


* *** * *** * **** * *
* * *** ** * ** **** *** (i >= l/2)
* *** * **** * *** ** ** ** * ****** ** * ** ("%s is a * * * ** *



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

#include <stdlib.h>

#include <string.h>

int main ()

{
*** *** ***** *** * * i,l;
** * ****** **** ** * *** str[100];
*** *** * * **
** * * ** * ** * * * ** * **
* * * ***** **** **** ******* * ** *** ***** * ("%s",str);
*** *** *** ** * * * ****** *** * ** *** ** ****
* ** * * * ** * * ** *** **** * * *** (i=0 ;i<l/2 ;i++)
** * ** * ** ** **** * ** * ** * ****
***** *** *** * ** * * **** * * ** ** *** * ** ****** ** (str[i] != str[l-i-1])
****** *** * * *** ** ** ** * * ** ** ***** * * * ** *** **** ** ** ** * ** *** * * *** * *
* * ** ** ** *** ***** **** * ** *** **** * ** * * **** * *** ** ***** ** * **** * **** * * ** * * * ("%s is not a palindrome\n",str);
** * ** * ** *** *** ** * * * ** * **** ** * * * * * ** * * * * * * ****** * ******* * * *** **
* * * * ** * ** ** *** * * *** * **** * ** ** **** ** ***** * **** **** * *


* * * ** * ** ** * * * * ** * ** ***
** * ** * * ** **** ** ***** * * ** * * (i >= l/2)
* **** ** * * * ** * * *** * * ** * * * * *** * * **** ("%s is a palindrome\n",str);

    }

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

#include <stdlib.h>

#include <string.h>

int main ()

{
**** * * ** * * i,l;
* * *** ** * * *** str[100];
* * ** * *** * ***** * *
* * *** * * * ** * ***
* * * * * ***** * * * ***** ** ** ** * ****** ***** * ("%s",str);
* **** ** ***** * *** * ** ** ** * * ** ****
* * ** * ** ******* ** ** ******* * * * * * (i=0 ;i<l/2 ;i++)
* *** ***** * ***** ** *** * * * **** * * * *****
* * * * *** *** * ** ** * *** ** ** * * * * ** *** * * ** * (str[i] != str[l-i-1])
** ** * **** *** ** * * * * * * ** ** * * *** * * ****** * * **
**** * * * * ** *** * ***** * * ** **** * *** ** * ** * * ** * ** * * * *** ** * * * * * ** ** ("%s is not a palindrome\n",str);
***** * * * ** * * * ***** * ** ** * * *** ** * ***** ** * ** ***** ** ** * ** * * * *** ** * ****** * **
*** ** **** * * * *** * * ** * * ** * * * ** * * * ** ** * * * **


** ** * *** ** * *** * *** *
*** * * ** ***** * ** ** * * *** * * **** (i >= l/2)
* *** * * *** *** ** * * *** ** *** * ********* ** *** ** * * ("%s is a palindrome\n",str);

    }

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

#include  <assert.h>

#include  <stdlib.h>

#include <string.h>



int  main(void){

    int i,j=0,flag=0;
* * * ***** **** * * * *** * a[10],b[10];
* ******* ***** * ** *** ** **
* **** *** * *** * ** * *** ****
****** * ** * * *** * * * *** * * ** *


*** *** *** * * ** ** * * ** * ** ** -1;i--)

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

    }






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

    }

if(flag==0)
*** * *** * *** * ****** is a palindrome", a);
* * * **** * * ** ****
* **** * ** * * * ** * * ***** * ***** * **** * * * *** is not a palindrome", a);

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

#include  <assert.h>

#include  <stdlib.h>

#include <string.h>



int  main()

{
* *** ** * **** ** ** i,j=0,k=0;


* ** * * * * ***** * a[10],b[10];


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


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


** * ** ** *** * *** * -1;i--)

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

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

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


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


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

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

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

#include <string.h>

#include <ctype.h>

#include <math.h>

#include * * *** * *

#include *** * * ** **



int main(){
* * * * * * *** * c[1000];
* * * *** * ** * *** * * ** ** ** *
*** ** * **** * *** i=0,j=0;
** * ** ******* **** * tmp1=0,tmp2=0;
**** ****** **** ** * ** ** * a=0;
* * ** * ** * ** ** = strlen(c);//字串長
*** ****** * *** * * ** *** = * *** ****** ***


**** * * ** *** ** **** ** ** * *
** * * *** * * * * ** * * ** ** * != c[tmp1-1]){
* * *** * * * * **** * ** ** ** * * ** *** * * ***** *** * * ** * * *
* * *** * * ** ***** ** * * *** * ** ***
* * * ** * ** * * ** * * * ** **** ** ** * ***
* *** ** *** * ******* **
* * * ** * * *** * * * ***
* * ** * ** * *** * is not a ****** * ** * **
* * * *** * * * **
******** * ** * * * **** * * ** is a * * *
* ********* ** *** * * *** 0;

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

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
| 1.6k 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
| 23.3k 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
| 6k 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
| 7.2k 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
| 4.8k views
12,783 questions
183,442 answers
172,219 comments
4,824 users