P1308 [NOIP2011 普及组] 统计单词数
编译信息 编译失败
/tmp/compiler_iozyujbp/src: 在函数‘int main()’中:
/tmp/compiler_iozyujbp/src:11:8: 警告:‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations] gets(b); ^ In file included from /usr/include/c++/8/cstdio:42, from /tmp/compiler_iozyujbp/src:2: /usr/include/stdio.h:583:14: 附注:在此声明 extern char gets (char __s) __wur attribute_deprecated; ^~~~ /tmp/compiler_iozyujbp/src:11:8: 警告:‘char gets(char)’ is deprecated [-Wdeprecated-declarations] gets(b); ^ In file included from /usr/include/c++/8/cstdio:42, from /tmp/compiler_iozyujbp/src:2: /usr/include/stdio.h:583:14: 附注:在此声明 extern char *gets (char *__s) __wur attribute_deprecated; ^~~~ /tmp/compiler_iozyujbp/src:25:2: 错误:‘strlwr’在此作用域中尚未声明 strlwr(b); ^~~~~~ /tmp/compiler_iozyujbp/src:25:2: 附注:suggested alternative: ‘strstr’ strlwr(b); ^~~~~~ strstr
#include<iostream>
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int i=0,j=0,tot=0,k=0,n;
int c[100000];
char a[100000][10],b[11],d;
gets(b);
d=getchar();
while(d!='\n')
{
if(d==' ')
{i++; j=0;}
else
{a[i][j]=d;j++;}
d=getchar();
}
n=i;
//for(int i=0;i<n;i++)A
//puts(a[i]);
strlwr(b);
//puts(b);
for(int i=0;i<n;i++)
{
strlwr(a[i]);
//puts(a[i]);
}
for(int i=0;i<n;i++)
if(strcmp(a[i],b)==0)
{
//puts(a[i]);
tot++;
c[k]=i;
k++;
}
if(tot==0) cout<<-1;
else cout<<tot<<" "<<c[0];
return 0;
}
在家中编译器秒通过,在洛谷。。。。。。