#7433: 奇怪的CE


king8754 (TrueBlue)


#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? 

#7435: Re:奇怪的CE


passerr (20130326 0340 48)


簡單講就是 C 沒有bool

C99才有 _Bool