这道题提醒我两点:

1.break时一定要检查清楚

2.字符串直接赋值一定要注意结束符,最好能用strcpy

以上是debug的惨痛教训

  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4. #include <cstdlib>
  5. #include <cstdio>
  6. #include <cmath>
  7. #include <algorithm>
  8. #include <stack>
  9. using namespace std;
  10.  
  11. #define MEM(a,b) memset(a,b,sizeof(a))
  12. #define pf printf
  13. #define sf scanf
  14. #define debug printf("!/n")
  15. #define INF 1000
  16. #define MAX(a,b) a>b?a:b
  17. #define blank pf("\n")
  18. #define LL long long
  19.  
  20. char str[];
  21.  
  22. int main()
  23. {
  24. int n,i,j;
  25. while(~sf("%d",&n))
  26. {
  27. int cnt = ;
  28. bool flag=false;
  29. for(i = ;i<n;i++)
  30. {
  31. char tmp[];
  32. sf("%s",tmp);
  33.  
  34. if(tmp[]=='')
  35. {
  36. flag = true;
  37. continue;
  38. }
  39.  
  40. if(tmp[]!='')
  41. {
  42. strcpy(str,tmp);
  43. continue;
  44. }
  45. else
  46. {
  47. int len = strlen(tmp);
  48.  
  49. for(j = ;j<len;j++)
  50. {
  51. if(tmp[j]!='')
  52. {
  53. strcpy(str,tmp);
  54. break;
  55. }
  56. cnt++;
  57. }
  58. }
  59. }
  60. if(flag)
  61. {
  62. pf("0\n");
  63. continue;
  64. }
  65. if(strlen(str)==)
  66. {
  67. pf("1\n");
  68. continue;
  69. }
  70. pf("%s",str);
  71. while(cnt--){pf("");}
  72. blank;
  73. }
  74. return ;
  75. }

CodeForce 614B Gena's Code(水题)的更多相关文章

  1. Codeforces Round #339 (Div. 2) B. Gena's Code 水题

    B. Gena's Code 题目连接: http://www.codeforces.com/contest/614/problem/B Description It's the year 4527 ...

  2. HDU 4813 Hard Code 水题

    Hard Code Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...

  3. Best code水题之路

    BestCoder 2nd Anniversary: 1001.Oracle There is once a king and queen, rulers of an unnamed city, wh ...

  4. CodeForces 614B Gena's Code

    #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm& ...

  5. CODE FESTIVAL 2017 qual B B - Problem Set【水题,stl map】

    CODE FESTIVAL 2017 qual B B - Problem Set 确实水题,但当时没想到map,用sort后逐个比较解决的,感觉麻烦些,虽然效率高很多.map确实好写点. 用map: ...

  6. [CodeForces - 614B] B - Gena's Code

    B - Gena's Code It's the year 4527 and the tanks game that we all know and love still exists. There ...

  7. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar 水题

    A. Checking the Calendar 题目连接: http://codeforces.com/contest/724/problem/A Description You are given ...

  8. codeforce A. 2Char(水题,暴力)

    今晚发了个蛇精病,然后CF了,第一题这好难啊,然而水题一个,暴力飘过. 链接http://codeforces.com/contest/593/problem/A: 题意比较难懂吗?傻逼百度都翻译不对 ...

  9. Codeforces Round #339 Div.2 B - Gena's Code

    It's the year 4527 and the tanks game that we all know and love still exists. There also exists Grea ...

随机推荐

  1. java使用Redis7--分布式存储并实现sentinel主从自动切换

    前面实现了分布式存储,也实现了sentinel单点故障时主从自动切换,现在还需要一种机制,实现分布式存储下,单点故障时的主从自动切换. Server配置 # cd /usr/redis/src/tes ...

  2. Web Worker 使用教程(转)

    转自:http://www.ruanyifeng.com/blog/2018/07/web-worker.html 一.概述 JavaScript 语言采用的是单线程模型,也就是说,所有任务只能在一个 ...

  3. leetcode 198 打家劫舍 Python 动态规划

    打家劫舍 你是一个专业的小偷,计划偷窃沿街的房屋.每间房内都藏有一定的现金,影响你偷窃的唯一制约因素就是相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警. 给定 ...

  4. leetcode-268-Missing Number(异或)

    题目描述: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is ...

  5. 架构师养成记--26.vi/vim相关操作

    vi/vim命令模式插入模式 aio编辑模式 : aio就是vi/vim的插入模式命令    作用a         在光标后附加文本A         在本行末附加文本i         在光标钱插 ...

  6. MySQL与Redis实现二级缓存

    redis简介 Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库 Redis 与其他 key - value 缓存产品有以下三个特点: Redis支持数据的持久化, ...

  7. 关于开发环境无法运行applet

    测试一下IE java vm 如果没有正确显示出来,说明java vm插件没有装好: 我用Uninstalle 来清理注册表:重装jdk 1.6_45

  8. Highcharts图表.net版开源,支持webform 和 mvc3,完全开源

    Highcharts是一个制作图表的纯Javascript类库,主要特性如下: 兼容性:兼容当今所有的浏览器,包括iPhone.IE和火狐等等: 对个人用户完全免费: 纯JS,无BS: 支持大部分的图 ...

  9. C# 文件操作系列一

    在.Net环境中,所有关于文件操作的类都在System.IO命名空间下,注:在修改文件时,安全性显得格外重要,但是本随笔不过多讲述安全性,这里假设我们有足够的权限. 1.管理文件系统 先通过一幅图来了 ...

  10. HUE配置文件hue.ini 的Spark模块详解(图文详解)(分HA集群和HA集群)

    不多说,直接上干货! 我的集群机器情况是 bigdatamaster(192.168.80.10).bigdataslave1(192.168.80.11)和bigdataslave2(192.168 ...