2 条题解

  • 0
    @ 2025-10-2 23:05:23

    涉及到字符串的相关常用函数,如strcspn,memcmp,strlen,strncpy等,熟练掌握这些函数之后即可轻松完成此题。

    #include<string.h>
    #include<stdlib.h> 
    #include<math.h>
    
    int main(){
    	int i;
    	char a[105];
    	char b[4];
    	char bao[4]={'a','w','a','w'};
    	char she[4]={'y','a','y','a'};
    	fgets(a,105,stdin);
    	a[strcspn(a,"\n")]=0;
    	int n=strlen(a);
    
    	for(i=0;i<=n-4;i++){
    		strncpy(b,&a[i],4);
    		
    		if(memcmp(b,bao,4)==0){
    			printf("zhishixuebao");
    			return 0;
    		}
    		else if(memcmp(b,she,4)==0){
    			printf("zhishisheli");
    			return 0;
    		}
    	}
        return 0;
    }
    

    信息

    ID
    53
    时间
    1000ms
    内存
    256MiB
    难度
    4
    标签
    递交数
    296
    已通过
    137
    上传者