zoukankan      html  css  js  c++  java
  • [洛谷P1580]yyy loves Easter_Egg I

    题目大意:很多人@一个人,如果那个人忍不住说话了,就轰炸成功,如果那个人没说话或者别的人没有@他或@很多个人,则轰炸失败。(具体见原题)

    解题思路:字符串处理,好好用sscanf即可(细节见代码)。

    C++ Code:

    #include<cstring>
    #include<algorithm>
    #include<cstdio>
    char s[1050],zha[1050],shuohua[1050],At[1050];
    int q=1;
    int main(){
    	fgets(s,1005,stdin);
    	sscanf(strstr(s,"@"),"@yyy loves %s",zha);
    	while(1){
    		fgets(s,1005,stdin);
    		if(strlen(s)<5)break;//读入结束
    		++q;
    		sscanf(s,"yyy loves %s",shuohua);
    		if(strcmp(zha,shuohua)==0){//油炸成功 
    			printf("Successful @yyy loves %s attempt
    ",zha);
    			return 0;
    		}
    		if(std::count(s,s+strlen(s),'@')!=1){//队形被破坏,油炸失败
    			printf("Unsuccessful @yyy loves %s attempt
    %d
    yyy loves %s
    ",zha,q,shuohua);
    			return 0;
    		}else{
    			sscanf(strstr(s,"@"),"@yyy loves %s",At);
    			if(strcmp(At,zha)){//队形被破坏,油炸失败
    				printf("Unsuccessful @yyy loves %s attempt
    %d
    yyy loves %s
    ",zha,q,shuohua);
    				return 0;
    			}
    		}
    	}
    	//队形没有被打破
    	printf("Unsuccessful @yyy loves %s attempt
    %d
    Good Queue Shape
    ",zha,q);
    	return 0;
    }
    
  • 相关阅读:
    Alluxio部署(local模式)
    spring boot热部署
    zeppelin部署
    hbase集群搭建
    spark集群模式
    spark单机模式
    ssh免密码登录配置
    error: not found: value sc
    sublime插件
    sublime和webstorm安装zencoding
  • 原文地址:https://www.cnblogs.com/Mrsrz/p/7248338.html
Copyright © 2011-2022 走看看