社区讨论
想请问一下为什么运行正常,代码提交就显示好多问题,百度完也没怎么看明白
P1308[NOIP 2011 普及组] 统计单词数参与者 3已保存回复 2
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 2 条
- 当前快照
- 1 份
- 快照标识符
- @lo9k5i92
- 此快照首次捕获于
- 2023/10/28 12:44 2 年前
- 此快照最后确认于
- 2023/10/28 12:44 2 年前
C
#include <stdio.h>
#include <string.h>
int main()
{
int i,n,m,j,k=0,e,t=0;
char a[11]={'\0'},b[1000001]={'\0'};
gets(a);
gets(b);
strupr(a);
strupr(b);
strcat(a," ");
strcat(b," ");
m=strlen(a);
n=strlen(b);
for(i=0;b[i]!='\0';i++)
{
if(i==0||b[i-1]==' ')
for(j=0;j<m;j++)
{
if(b[i+j]!=a[j])
break;
}
if(j==m)
{
t=1;
e=i;
break;
}
}
if(b[i]=='\0')
t=0;
if(t==1)
{
for(i=0;i<n;i++)
{
if(i==0||b[i-1]==' ')
for(j=0;j<m;j++)
{
if(b[i+j]!=a[j])
break;
}
if(j==m)
{
k++;
i+=m-1;
}
}
printf("%d %d",k,e);
}
if(t==0)
printf("-1");
return 0;
}
/tmp/compiler_06p4qay4/src: 在函数‘int main()’中:
/tmp/compiler_06p4qay4/src:7:5: 错误:‘gets’ was not declared in this scope; did you mean ‘fgets’?
7 | gets(a);
| ^~~~
| fgets
/tmp/compiler_06p4qay4/src:9:5: 错误:‘strupr’ was not declared in this scope; did you mean ‘strstr’?
9 | strupr(a);
| ^~~~~~
| strstr
/tmp/compiler_06p4qay4/src:31:5: 警告:this ‘if’ clause does not guard... [-Wmisleading-indentation]
31 | if(b[i]=='\0')
| ^~
/tmp/compiler_06p4qay4/src:33:9: 附注:...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
33 | if(t==1)
| ^~
/tmp/compiler_06p4qay4/src:51:3: 警告:this ‘if’ clause does not guard... [-Wmisleading-indentation]
51 | if(t==0)
| ^~
/tmp/compiler_06p4qay4/src:53:5: 附注:...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
53 | return 0;
| ^~~~~~
回复
共 2 条回复,欢迎继续交流。
正在加载回复...