题目其实不难,但是要注意题目的要求,当前字数(>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. serialize

    Jquery的serialize()方法用于将表单元素转换为查询字符串格式, Submit按钮及File选择元素是不能序列化的. $('input:button').click(function() ...

  2. WPF的TextBox的焦点获取与失去焦点的死循环解决方案

    在WPF中实现一个弹出层自动获取焦点,弹出层实现是通过其UserControl的依赖属性Visibility的绑定实现的,让UserControl上的TextBox获取焦点,初始实现代码如下: pub ...

  3. Java实战之04JavaWeb-02Request和Response

    一.Response和Request的生态环境 二.HttpServletResponse---代表响应对象 1.设置状态码 void setStatus(int sc) 状态码: 200:一切正常 ...

  4. Qt-获取网络接口信息的综合示例

    在前面的文章中介绍了与 获 取 本 机 网 络 信 息 相 关 的 类 常 用 的 有 4 个 , 分 别 是 : QHostAddress, QHostInfo, QNetworkInterface ...

  5. Mac 平台下安装 OpenVC

    opencv for Mac I 背景 Mac(Ios 9.0), 时间: 2015年11月.       本人也是小白,在网上爬了几天才安装好. II 安装OpenCV for Mac 首先下载op ...

  6. 《Nodejs开发加密货币》之二十七:开发通用的HTML组件

    人的懒惰常常是麻烦的开始.多数程序员都希望自己的工作一劳永逸,一次开发,到处使用,成了人人追逐的目标,我也不例外.最初写<Nodejs开发加密货币>系列文章,因为不喜欢设定好了去写,所以目 ...

  7. WPF一个简单的垂直菜单样式的实现

    以前制作类似于垂直菜单功能的控件我都是Listbox和一个Popup实现的,今天尝试着用Menu做了一个简单垂直菜单,就当是做了个小练习写了这篇随笔~: 有什么不对的地方希望大家指正,分享和记录也是一 ...

  8. Vijos P1063 迎春舞会之交谊舞 DP

    题目链接:https://vijos.org/p/1063 题意:有n(n <= 100)行,每行有2*i-1个可显字符'#'与'-',组成一个倒三角形,问由'-'组成的最大三角形的'-'的个数 ...

  9. ColorDialog组件设置字体颜色

    1.设置颜色 private void button4_Click(object sender, EventArgs e) { this.colorDialog1.ShowDialog(); this ...

  10. 用android-x86模拟器不能运行程序错误Tag:libc的问题

    如果用的是x86的android模拟器,运行软件时一闪就关闭logcat中:类似:Fatal signal 11 (SIGSEGV) at 0x00000078 (code=1), thread 16 ...