题目其实不难,但是要注意题目的要求,当前字数(>0)+当前单词长度+1若超过80则需要回车后,输出当前word,并且重新计数。这道题目的数据感觉比较水,不过测试的时候,最后使用fprintf输出在文件中,便于观察。

 #include <stdio.h>
#include <string.h> #define MAXNUM 85 char line[MAXNUM];
char word[MAXNUM]; int main() {
int i;
int num=, len;
//FILE *fout = fopen("data", "w"); while (scanf("%s", word) != EOF) {
if (strcmp(word, "<br>") == ) {
printf("\n");
//fprintf(fout, "\n");
num = ;
continue;
}
if (strcmp(word, "<hr>") == ) {
if (num)
printf("\n");
//fprintf(fout, "\n");
for (i=; i<; ++i)
printf("-");
//fprintf(fout, "-");
printf("\n");
//fprintf(fout, "\n");
num = ;
continue;
}
len = strlen(word);
if (num) {
if (num+len+ > ) {
printf("\n%s", word);
//fprintf(fout, "\n%s", word);
num = len;
} else {
printf(" %s", word);
//fprintf(fout, " %s", word);
num += len+;
}
} else {
printf("%s", word);
//fprintf(fout, "%s", word);
num += len;
}
}
printf("\n");
//fclose(fout); return ;
}

【HDOJ】1088 Write a simple HTML Browser的更多相关文章

  1. HDOJ/HDU 1088 Write a simple HTML Browser(HTML字符串)

    Problem Description If you ever tried to read a html document on a Macintosh, you know how hard it i ...

  2. 【HDOJ】4267 A Simple Problem with Integers

    树状数组.Easy. /* 4267 */ #include <iostream> #include <string> #include <map> #includ ...

  3. 【HDOJ】2451 Simple Addition Expression

    递推,但是要注意细节.题目的意思,就是求s(x) = i+(i+1)+(i+2),i<n.该表达中计算过程中CA恒为0(包括中间值)的情况.根据所求可推得.1-10: 31-100: 3*41- ...

  4. 【HDOJ】4972 A simple dynamic programming problem

    水题. #include <cstdio> #include <cstring> #include <cstdlib> int abs(int x) { ? -x: ...

  5. 【HDOJ】1341 Simple Computers

    注意PC要与31. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 40 ...

  6. 【HDOJ】1497 Simple Library Management System

    链表. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXM 1001 #def ...

  7. 【HDOJ】4729 An Easy Problem for Elfness

    其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...

  8. 【设计模式】简单工厂模式 Simple Factory Pattern

    简单工厂模式Simple Factory Pattern[Simple Factory Pattern]是设计模式里最简单的一个模式,又叫静态工厂模式[Static Factory Pattern], ...

  9. 【HDOJ】【3506】Monkey Party

    DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...

随机推荐

  1. C#程序员整理的Unity 3D笔记(十):Unity3D的位移、旋转的3D数学模型

    遇到一个想做的功能,但是实现不了,核心原因是因为对U3D的3D数学概念没有灵活吃透.故再次系统学习之—第三次学习3D数学. 本次,希望实现的功能很简单: 如在小地图中,希望可以动态画出Player当前 ...

  2. @Transactional详解

    @Transactional     spring 事务注解 默认遇到throw new RuntimeException("...");会回滚需要捕获的throw new Exc ...

  3. 关于main函数的定义

     很多人甚至市面上的一些书籍,都使用了void main( ),其实这是错误的.C/C++中从来没有定义过void main( ).C++之父Bjarne Stroustrup在他的主页上的FAQ中明 ...

  4. javaee学习-新建servlet 直接返回html

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletExcepti ...

  5. jquery的effect-color对easyui没效果.自己冒险写个边框的颜色闪烁.

    "jquery-ui-effect-color.js" 是从jqueryui下载的color动画部分(自己改了个名字). 链接 <!DOCTYPE html> < ...

  6. Google 编码风格

    一.Google JavaScript编码风格 简体中文版 Google JavaScript Style Guide 二.Google HTML/CSS代码风格指南 简体中文版 三.Google C ...

  7. 数据库不能用delete---index空间不足

    只有0702表是这样的情况,0101表可以使用like和between and

  8. sql的集合操作

    原文转自:http://blog.csdn.net/qsyzb/article/details/12560917 SELECT语句的查询结果是元组的集合,所以多个SELECT语句的结果可进行集合操作. ...

  9. Unity帮助文档打开速度慢解决方法

    使用批量文本替换工具替换掉Unity安装目录中\Editor\Data\Documentation\en\Manual\下的所有文件中的如下两个部分:   1. <script type=&qu ...

  10. MVC 弹出提示框

    第一种弹框成功后要刷新界面 [HttpPost] public ActionResult Add(Maticsoft.Model.Project.ProjectMoneyPlan model) { m ...