Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

PE,求解

Posted by sdau_085111 at 2011-10-13 13:14:13 on Problem 2271
/**************************************************************************
* Problem: POJ 2271 HTML
* Copyright 2011 by Yan
* DATE:
* E-Mail: yming0221@gmail.com
************************************************************************/

#include <stdio.h>

char word[100];

int main()
{

	int len;
	int i;
	int cnt;
	int flag;/*标志上一个是不是<hr>*/
	cnt=0;
	while(scanf("%s",word)!=EOF)
	{
		len=strlen(word);


		if(strcmp(word,"<br>")==0) printf("\n"),cnt=0,flag=0;
		else if(strcmp(word,"<hr>")==0)
		{
			if(flag==0) printf("\n");
			cnt=0,printf("--------------------------------------------------------------------------------\n");
			flag=1;
		}
		else
		{
			flag=0;

			if(cnt+len>=80) printf("\n"),cnt=0,flag=0;

			if(cnt!=0) printf(" ");
			printf("%s",word);

			cnt+=len+1;
		}
	}
	printf("\n");
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator