在家中编译器秒通过,在洛谷......代码直接(?????)
  • 板块学术版
  • 楼主wangqz
  • 当前回复38
  • 已保存回复38
  • 发布时间2021/6/30 17:04
  • 上次更新2023/11/4 21:08:58
查看原帖
在家中编译器秒通过,在洛谷......代码直接(?????)
530676
wangqz楼主2021/6/30 17:04

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;
}

在家中编译器秒通过,在洛谷。。。。。。

2021/6/30 17:04
加载中...