a022.
迴文
| From: [203.67.210.49] |
發表日期
:
2013-01-28 13:57
#include <stdlib.h>
#include <stdio.h>
bool vaili(char*, int);
int main(void)
{
char s[100] = {'\0'};
while ((scanf("%s",&s)) != EOF)
{
int s_length = 0, i = 0;
while (s[i]!='\0')
{
i++;
s_length = i;
}
if (vaili(s, s_length))
printf("yes\n");
else
printf("no\n");
char s[100] = {'\0'};
}
return 0;
}
bool vaili(char* s, int length)
{
int j;
for (j = 0;j < (length/2);j++)
{
if(s[j] != s[(length-1-j)]) return false;
}
return true;
}
CE ()編譯錯誤code_1386032.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘vaili’ code_1386032.c:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘vaili’
但
#include <stdlib.h>
#include <stdio.h>
int vaili(char*, int);
int main(void)
{
char s[100] = {'\0'};
while ((scanf("%s",&s)) != EOF)
{
int s_length = 0, i = 0;
while (s[i]!='\0')
{
i++;
s_length = i;
}
if (vaili(s, s_length) == 1)
printf("yes\n");
else
printf("no\n");
char s[100] = {'\0'};
}
return 0;
}
int vaili(char* s, int length)
{
int j;
for (j = 0;j < (length/2);j++)
{
if(s[j] != s[(length-1-j)]) return 0;
}
return 1;
}
AC (0ms, 260KB)通過檢測
why?