HDU ACM 1088 Write a simple HTML Browser

题意:出现<br>换行,出现<hr>输出‘-’,每一行的加上现在的单词如果长度超过80则换行,每个单词前留一个空格,结束时要输出换行。

#include<iostream>
using namespace std;

int main()
{
	char s[100];
	int len,cnt=0;

	while(scanf("%s",s)==1)
	{
		if(!strcmp(s,"<br>"))
		{
			cnt=0;
			putchar('\n');
		}
		else if(!strcmp(s,"<hr>"))
		{
			if(cnt)
				printf("\n--------------------------------------------------------------------------------\n");
			else
				printf("--------------------------------------------------------------------------------\n");
			cnt=0;
		}
		else
		{
			len=strlen(s);
			if(!cnt)
			{
				cnt=len;
				printf("%s",s);
			}
			else if(cnt+len+1>80)
			{
				cnt=len;
				printf("\n%s",s);
			}
			else
			{
				cnt+=len+1;
				printf(" %s",s);
			}
		}
	}
	putchar('\n');
    return 0;
}
时间: 2024-11-06 22:25:39

HDU ACM 1088 Write a simple HTML Browser的相关文章

HDU 1088 - Write a simple HTML Browser

直接看sample input = = 又一道模拟. 1 #include <iostream> 2 #include <string> 3 #include <cstdio> 4 using namespace std; 5 string s; 6 int main() 7 { 8 // freopen("date.out","w",stdout); 9 int m=0; 10 while(cin>>s) 11 {

HDU ACM 1103 Flo&#39;s Restaurant

分析:借助STL的min_element实现.每次更新最先被占用的桌子,具体见注释. #include<iostream> #include<algorithm> using namespace std; int main() { int A,B,C; char s[10]; int a[102],b[102],c[102]; int curtime,count,ans; int *p; //桌子最先空闲时间 while(cin>>A>>B>>C

hdu acm 1425 sort(哈希表思想)

sort Time Limit: 6000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 25803    Accepted Submission(s): 7764 Problem Description 给你n个整数,请按从大到小的顺序输出其中前m大的数. Input 每组测试数据有两行,第一行有两个数n,m(0<n,m<1000000),第二行包含n个各不相同,且

HDU ACM 1005 Number Sequence

Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 119732    Accepted Submission(s): 29072 Problem Description A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A

hdu acm 1166 敌兵布阵 (线段树)

敌兵布阵 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 37903    Accepted Submission(s): 15985 Problem Description C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了.A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务

HDU ACM 1025 Constructing Roads In JGShining&amp;#39;s Kingdom-&amp;gt;二分求解LIS+O(NlogN)

#include<iostream> using namespace std; //BFS+优先队列(打印路径) #define N 500005 int c[N]; int dp[N]; //dp[i]保存的是长度为i的最长不降子序列的最小尾元素 int BS(int n,int x) //二分查找下标,当x比全部元素小时下标为1,比全部元素大时下标为n+1. { int low,high,mid; low=1,high=n; while(low<=high) { mid=(low+h

杭电 HDU ACM 圆桌会议

圆桌会议 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3356    Accepted Submission(s): 2351 Problem Description HDU ACM集训队的队员在暑假集训时经常要讨论自己在做题中遇到的问题.每当面临自己解决不了的问题时,他们就会围坐在一张圆形的桌子旁进行交流,经过大家的讨论后一般没有

杭电OJ(HDU)-ACM Steps-Chapter Two-《Biker&#39;s Trip Odometer》《Climbing Worm》《hide handkerchief》《Nasty Hac》

1.2.1 Biker's Trip Odometer #include<stdio.h> #include<math.h> const double PI=acos(-1.0); /* 计算题,根据公式做就行,PI*d*r/(12*5280);res1/t*3600; Sample Input 26 1000 5 27.25 873234 3000 26 0 1000 Sample Output Trip #1: 1.29 928.20 Trip #2: 1179.86 1415

HDU ACM 1098 Ignatius&#39;s puzzle

分析:裴蜀定理,a,b互质的充要条件是存在整数x,y使ax+by=1.存在整数x,y,使得ax+by=c,那么c就是a,b的公约数. 假设存在数a ,因为对任意x方程都成立,则有当x=1时f(x)=18+ka;有因为f(x)能被65整除,所以f(x)=n*65.即18+ka=n*65有整数解则说明假设成立. ax+by = c的方程有整数解的一个充要条件是:c%gcd(a, b) == 0.然后枚举直到(65*n-18)%k == 0. #include<iostream> using nam