【HDOJ】1088 Write a simple HTML Browser
题目其实不难,但是要注意题目的要求,当前字数(>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的更多相关文章
- 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 ...
- 【HDOJ】4267 A Simple Problem with Integers
树状数组.Easy. /* 4267 */ #include <iostream> #include <string> #include <map> #includ ...
- 【HDOJ】2451 Simple Addition Expression
递推,但是要注意细节.题目的意思,就是求s(x) = i+(i+1)+(i+2),i<n.该表达中计算过程中CA恒为0(包括中间值)的情况.根据所求可推得.1-10: 31-100: 3*41- ...
- 【HDOJ】4972 A simple dynamic programming problem
水题. #include <cstdio> #include <cstring> #include <cstdlib> int abs(int x) { ? -x: ...
- 【HDOJ】1341 Simple Computers
注意PC要与31. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 40 ...
- 【HDOJ】1497 Simple Library Management System
链表. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXM 1001 #def ...
- 【HDOJ】4729 An Easy Problem for Elfness
其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...
- 【设计模式】简单工厂模式 Simple Factory Pattern
简单工厂模式Simple Factory Pattern[Simple Factory Pattern]是设计模式里最简单的一个模式,又叫静态工厂模式[Static Factory Pattern], ...
- 【HDOJ】【3506】Monkey Party
DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...
随机推荐
- JavaScript高级程序设计(七):JavaScript中的in关键字
in 使用点一: 在js中,for--in用于遍历一个对象的属性,把对象的属性名和属性值都提出来. var obj = { "key1":"value1", & ...
- IOS开发之NSPredicate谓词的用法
编程的人员不管是上过大学还是从培训机构出来的或做后台的.前端的都应该SQL语句有所了解,我们知道,在SQL语句当中 where 条件表达式可以对二维关系表的数据做条件筛选.微软的C# .net中也实现 ...
- 学习C++ Primer 的个人理解(七)
类,后面还有两章是介绍有关于类的内容的.这一张依然只是个概括.但也已经将大致用法介绍完了. 重点如下: 1.成员函数的声明,必须在类的内部. 2.引用const成员函数 我们知道成员函数中有一个名为t ...
- [翻译][MVC 5 + EF 6] 8:更新相关数据
原文:Updating Related Data with the Entity Framework in an ASP.NET MVC Application 1.定制Course的Create和E ...
- ThinkPHP3.2 加载过程(一)
加载过程(官方介绍) : 用户URL请求 调用应用入口文件(通常是网站的index.php) 载入框架入口文件(ThinkPHP.php) 记录初始运行时间和内存开销 系统常量判断及定义 载入框架引导 ...
- mysql的1045解决方法
mysql的连接方式有两种: UNIX域套接字连接,如: mysql -u root -p mysql -h localhost -u root -p TCP/IP套接字连接,如: mysql -h ...
- 前端资源多个产品整站一键打包&包版本管理(四)—— js&css文件文件打包并生成哈希后缀,自动写入路径、解决资源缓存问题。
问题: 当我们版本更新的时候,我们都要清理缓存的js跟css,如何使得在网页中不需要手动清理呢? 答案: 生成带有哈希后缀的js跟css文件 1.文件路径 路径中的conf.js 是用于放置全局打包的 ...
- Python调试工具-Spyder
OS:Windows 7 关键字:Python IDE, Spyder 1.安装工具pip:https://pip.pypa.io/en/latest/installing.html 下载 get-p ...
- C#表驱动法+一点反射实现“得到指定位数随机不重复字符串”三种方式的封装
1.结构 第一个类 public class GetMethods{...} 类中的变量: ...
- Hbase实例
import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.apache.had ...