【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 ...
随机推荐
- Oracle归档已满的处理办法
SqlPlus: / as sysdba select * from V$FLASH_RECOVERY_AREA_USAGE; show parameter log_archive_dest; sho ...
- SQL SERVER删除列,报错."由于一个或多个对象访问此列,ALTER TABLE DROP COLUMN ... 失败"
队友给我修改数据的语句.总是执行失败.很纳闷. 如下图: 仔细看了下这个列,并没有什么特殊.如下图: 但其确实有个约束: 'DF__HIS_DRUG___ALL_I__04E4BC85' . 为什么有 ...
- 常用Linux/Unix/Mac Os命令
常用Linux/Unix/Mac OS命令 参考: 1.50 Most Frequently Used UNIX / Linux Commands (With Examples)
- 模板:qsort+bsearch应用
(1)qsort: 功 能: 使用快速排序例程进行排序 头文件:stdlib.h 用 法: void qsort(void *base,int nelem,int width,int (*fcmp)( ...
- Linux与Windows的桥梁--共享目录
1.关闭防火墙和selinux # service iptables stop # chkconfig --level 2345 iptables off ...
- 解决rtl8723be无线网卡驱动频繁断网问题
买了新本子,用的是rtl8723be无线网卡,连WIFI时总是断网.Windows下好解决,Ubuntu下可就麻烦了,又是升级内核又是编译驱动的,折腾了一天,终于找到了解决办法: # echo &qu ...
- jQuery(function(){})与(function(){})(jQuery)的区别
jQuery(function(){ });/$(function(){ });全写为 $(document).ready(function(){}); 意义为在DOM加载完毕后执行了ready()方 ...
- 创建安全的ashx文件,ashx编译
<%@ WebHandler Language="C#" Class="Handler2" %> using System; using Syste ...
- dedecms 获取文章发布时间和获取文章最后更新时间
文章发布时间:[field:senddate function=MyDate('m-d',@me)/] 文章最后更新时间:[field:pubdate function=MyDate('m-d',@m ...
- 使用内核定时器的second字符设备驱动及测试代码
驱动: #include <linux/kernel.h> #include <linux/module.h> #include <linux/fs.h> #inc ...