3 like 0 dislike
1.2k views
迴文判斷

迴文是指一個字串從前面讀過去跟從後面讀過去是一樣的

所以 abcdcba 是一個迴文

請寫一個程式判斷書入的字串是不是迴文

輸入說明:

會輸入一個字串,字串中間不會包含空白字元

輸出說明:

如果輸入的字串是迴文,請輸出YES,反之則輸出NO

輸入範例:

abcdcba

輸出範例:

YES
[Exercise] Coding (C) - asked in 2017-1 程式設計(一)AD by (18k points)
ID: 33757 - Available when: Unlimited - Due to: Unlimited
| 1.2k views

22 Answers

0 like 0 dislike
Hidden content!
** ******* * ***** * * *
*** * **** * * **
int main()
{
* * ** ** *** char ****
* * * * ** int a,b,c;
* *
* ** ** ** * * * ** ** * EOF)
*** **** {
* * * ** * *** * * b = 1;
*** * * * * * ** * ** * a = *** * *
**** ** * *** * ** ** * * ***
****** *** *** * *** *** **** a/2;c++)
* * * * **** * ** {
* * * *** **         ** *** * *
*** *   *     * * {
*** **   * ***** *** * * * ** * * * * b=0;
* * * * ** * *** * **** * * * break;
* * *** **** * *** *** ** *** * * * }
* **** **** * * ** }
** * * ** * * ** *** * if(b)
** ** * *** * * * * ** * ** * * * * * * * * *
** *** * * * * * * * * * else
* * * * *** ** * ** * ** ** * **** * *** ** * * * * ******* **** * * *
** * * * ** * * * * **** * * ** ** **
* ** * ** *** * * * * * ***** break;
*** *** }
* *** * ****
* * ** * return 0;
** * * *** *** ** * *
** ***
answered by (160 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <string.h>
#include <string.h>
void main(){
* *** * * ***** * * ** * s[100];  
* ** * * * ** * ** **** *** i, j, n;
*** * * ** *** ** **** * ****** ***** ** ** *
** * ** ** * * ****** ***** * *
    
* *** * * ***** ***** **
*** ** ** ** ** * *** * *** * *** **
** ** * * * * * * ****** **** ***** * ** *** * ** * break;
****** ** *** **** * * **** * * *** *** **** * **
** ** * * * ** * ** * ***** * ** *** * * * * * * ** * ** *** **** ** *** * **
* *** **** * **** ** * * ** * * ** ** * ** **
**** * ****** * ** * * * **** ** * ** * *** ** * *** *** **** * ** * ** * **** ** *
}
answered by (160 points)
0 0
prog.c: In function 'main':
prog.c:8:5: warning: 'gets' is deprecated [-Wdeprecated-declarations]
     gets(s);
     ^~~~
In file included from prog.c:1:0:
/usr/include/stdio.h:640:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/cco06mfq.o: In function `main':
prog.c:(.text+0x30): warning: the `gets' function is dangerous and should not be used.
0 like 0 dislike
Hidden content!
** *** * ** * *
** ** **** * *
int main()
{
* * * ** * char *
** * ** int a,b,c;
* * ** **
* **** * * * * *** * * * ** ** * ** EOF)
**** **   {
** * * *** * ** ** * b = 1;
* ******* * ** * * * a = * * **
** * ****** * * ** *
* ** * ** * **** * ** *** * * a/2;c++)
* *** * * * ** * {
* *** *** * ***     ** ** *
**     ****     {
** *** ** *** ** * * * ** * * * * * ** * b=0;
* ** ** **** ***** ****** ** * * * ** break;
* * * ** * * * ** * * *** }
* * * * * * * * }
****** *** ** * * * * * if(b)
*** *** * * ** ** * * * ******* * * ** ** ** ** * ** *
** * ** * * ** ** * * else
* *** ** ** *** * **** ** * *** ***** * * * ** ***** *** ******* * ***
* * ** }

* ** * * * return 0;
** *** ** ***** ** *****
** *
answered by (160 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
* *** * * ** * *** * * u,m;
** ******* ****** * ** * sum=0;
** *** * *** * * *** ** * ** * * * **** * * * *
* * * ** ** * * *** *** *** ** * *
* * ** * ** * ****** ***
******** *** ** ** ** *
    {
***** ** * ** ******* *
***** ** * *******
    }
* ** ***** **** *** ** ** *** * *
** * ** *** ** ** ** *** * ***** * *** * ** * ("u是回文数");
* * * * *** *** * * ** *
* ***** * ** * **** * * ** ** * **** **** * ** * ** ***
** * * ** * ***** ** ** *** **** *
* ** * ** * *** * ** *** * * 0;
}
answered by (160 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
0 like 0 dislike
Hidden content!
* *** * ** * **
int main()
{
** * int n,m,t;
* ** ** * ***** * ** * ***
* ** ** * * {
*** * * * * ** * * t=n;
** *** * * * *** ** * * m=0;
**** * ** * * * * ** while(t)
*** ** * * * * {
* * ** **         ** ****
* ****   * *** * * * * * * * t/=10;
* * ** * * * * * * ** * }
*** * ** *** ** *** ** * * if(m==n)
*** * ** * ** ** {
* * * ** *** * ** * * ** * ** * * ** ** * * * *
** *** ** ** * * * * }
* ** * ** * * ** *** **** else
* * * * ** * * ** * * {
** **** **** ** * *** * ** ** * ** * * **** * * ** *
** * * * * * }
**** * * *** * }
* *** * * * return 0;
}
answered by (160 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
0 like 0 dislike
Hidden content!
* * * * * ** * ** ****
int main()
{
** ** *** ** char * * *
** * * * ** int a,b,c;
**** *** *
* * ***** * * * * * *** ** * ** EOF)
** * *** {
** * ** * * * * * * * b = 1;
** * * * *** * *** **** a = ** ***
* * ** ** * ** * ***
* ** ** ** ** ****** ** * ***** * a/2;c++)
*** *** *     {
* **     *** **     ** ***
* *** ** ** * ** * * ** **** ** {
*** * ** **   * ***** * **** * *** *** * * * b=0;
* *** * * * ** * *** **** *** * ** * ** break;
**** ** * *** * *** * * }
* ** ** * * ** * * ** }
** * * ** ** * * * if(b)
** ** * * *** **** ** **** * * * * * *
* * ** *** * ** * * ** else
* *** ** *** **** * ** *** *** * * * ** * * **** *** ***** **
*** * }
* * *** *** *
******** * return 0;
** * * *** * ** ** **
*** * ***
answered by (160 points)
0 0
prog.c: In function 'main':
prog.c:10:7: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
   a = strlen(str);
       ^~~~~~
prog.c:10:7: warning: incompatible implicit declaration of built-in function 'strlen'
prog.c:10:7: note: include '<string.h>' or provide a declaration of 'strlen'
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
    int i,n=0,k=0;
    char a[1000];
*** * * * ** ** * * * **** *** ******
* *** ***** * * * *** *
    {
* **** ** ** * * * ******** **** * **** *** * * *** * ** * * * * ** ** **** * ** ** ***** * *** * * *** *** * *** ** * ** * * *** ** * * *** ** * * * ** * * * ** **
    }
* * ** * * * * * * * ** ** **
    {
* *** * * * * * * *** * *** ** ** * ***** * * *** ***** * * ** * ** * * * * * * * **** ** * * * * * *
* * ****** * * * ** * *** ** ** * ** * * * *** * * * * ******* * * **** * * * *** * ** ** ** * * ** * **
* * * ** * * ** ** * **** * *** * * * *** **** *** * **** ** * * * * ** ** * * * *********** * *** * * * * *** * * * * ** ** * * ** *** ** ** *** * * ** * * *** * *** ** * **
* ***** ** * * *** * * ** * *** ** ** ** *** *** *** * * ** * *** ***** * ******* ** * * **** ** *** *** *
    }
* **** ******* ** ** *
*** *** * ** * ***** ** * **** **
    else
* * ***** ** * ** *** * * ** * *** * * *

    return 0;
}
answered by (215 points)
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main()
{
    //32
    char a[20]={0};
    int n;
* * * ** * ** * * * * *** ****** **
    {
* * * * * * * * ** * * * * * * flag=1;
*** ** * * * ** ** * ***** * * **** *** *** i,j;
* * ** * * ** ***** *** ** * * ** * * ** *
* * ***** ** ** * **** * * *** ** **

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

    return 0;
}
answered by (114 points)
0 0
Case 0: Correct output
Case 1: Correct output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <stdlib.h>

int main()
{
    //32
    char a[20]={0};
    int n;
* * ** * *** *** * * * **** * ***** * ** * * *
    {
* **** ** * *** * * *** * * ** **** flag=1;
* *** *** ***** **** *** **** *** * *** * i,j;
** * * * ****** * ** *** * ** * * ***** * * ** * ** * * ** **
* ***** * ** **** * *** ** * * *** * ** *

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

    return 0;
}
answered by (114 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main()
{
* *** * ***** ** n,i,same=0;
**** * * * ** ** a[999];
****** ***** * ** * ** * *** *** *
*** ** * * *** ** * ***** *
    
**** * ** ** ****** ********** **
    
** * * ** * ** * ***** ** * *** ******
* ******* **** *** *****
* ** ***** *** * * ** * * * * ** * ** * *** **
*** * *** * ** * * ** * ** *
* * ** * * ** * * ***** * * * ********** * *** ** * *
* ***** ** *** ***** **** * ** * *
* * * * * * * ** ** * *** * * * * * * ** **** ** **** * *
** ** ** ** * ** ** *** *** ** * * ** * * * **** * **** **
* ** * *** * * *
* * * * ** ** * * * *
*** *** ********** ** *** ** *** * * ** * **
* **** * ** *****
* * * *** * * ***** **** *** * ******** ** *
    
    
}
answered by (192 points)
0 0
Case 0: Correct output
Case 1: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.6.155
©2016-2024

Related questions

2 like 0 dislike
24 answers
[Exercise] Coding (C) - asked Nov 16, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
ID: 33762 - Available when: Unlimited - Due to: Unlimited
| 987 views
3 like 0 dislike
20 answers
[Exercise] Coding (C) - asked Nov 16, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
ID: 33758 - Available when: Unlimited - Due to: Unlimited
| 1.1k views
3 like 0 dislike
9 answers
[Exercise] True/False - asked Nov 16, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 33763 - Available when: 2017-11-16 14:00 - Due to: 2017-11-16 14:30
| 231 views
3 like 0 dislike
5 answers
[Exercise] Coding (C) - asked Nov 30, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
ID: 34978 - Available when: Unlimited - Due to: Unlimited
| 459 views
3 like 0 dislike
6 answers
[Exercise] Coding (C) - asked Nov 30, 2017 in 2017-1 程式設計(一)AD by Shun-Po (18k points)
ID: 34979 - Available when: Unlimited - Due to: Unlimited
| 426 views
12,783 questions
183,443 answers
172,219 comments
4,824 users