#7433: 奇怪的CE


king8754 (TrueBlue)

學校 : 國立彰化高級中學
編號 : 9963
來源 : [114.35.165.133]
最後登入時間 :
2017-10-14 18:55:26
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? 

 
#7435: Re:奇怪的CE


passerr (20130326 0340 48)

學校 : 不指定學校
編號 : 8516
來源 : [125.224.93.117]
最後登入時間 :
2024-09-05 12:09:52
a022. 迴文 | From: [125.231.39.229] | 發表日期 : 2013-01-29 00:32

簡單講就是 C 沒有bool

C99才有 _Bool

 
ZeroJudge Forum