Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
125049 陈华仁星 如何得到"hello" C++ Compile Error 0 MS 0 KB 574 2025-07-13 10:47:39

Tests(0/0):


Code:

#include <iostream> #include <cstring> using namespace std; char a[1500]; char b[10]="hello"; int main() { scanf("%s",a); int len = strlen(a); int k=0; for(int i=0;i<len;i++) { if(a[i]==b[k]) k++; } if(k>4) printf("YES"); else printf("NO"); return 0; }#include <iostream> #include <cstring> using namespace std; char a[1500]; char b[10]="hello"; int main() { scanf("%s",a); int len = strlen(a); int k=0; for(int i=0;i<len;i++) { if(a[i]==b[k]) k++; } if(k>4) printf("YES"); else printf("NO"); return 0; }


Run Info:

Main.cc:21:2: error: stray '#' in program
 }#include 
  ^
Main.cc:21:3: error: 'include' does not name a type
 }#include 
   ^
Main.cc:24:12: error: redefinition of 'char a [1500]'
 char a[1500];
            ^
Main.cc:4:6: note: 'char a [1500]' previously declared here
 char a[1500];
      ^
Main.cc:25:10: error: redefinition of 'char b [10]'
 char b[10]="hello";
          ^
Main.cc:5:6: note: 'char b [10]' previously defined here
 char b[10]="hello";
      ^
Main.cc: In function 'int main()':
Main.cc:26:5: error: redefinition of 'int main()'
 int main()
     ^
Main.cc:6:5: note: 'int main()' previously defined here
 int main()
     ^
Main.cc: In function 'int main()':
Main.cc:8:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",a);
               ^
Main.cc: In function 'int main()':
Main.cc:28:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",a);
               ^