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

一个很简单的规律 但要注意几个细节

Posted by Nstd at 2011-08-16 11:39:42 on Problem 1750
初始空格数 blank = 0; i = 1; s[0][0] = '\0'; (用滚动数组可以减少内存)

如果当前串S[i]与前一个串s[i-1]的前缀长度sp小于等于blank
则令blank等于sp,否则令blank ++
然后输出blank个空格

输出可以通过格式控制进行输出: printf("%*s\n", blank+strlen(s[i]), s[i]);

我先是PE了2次(感觉应该是WA),原因是NC地把第一个串直接输出了(可能是数据的问题)
改正后一直OLE,经小溪指点,发现可能有两个连续相同的串,由于在比较的时候没有加串结束的终止条件,所以会多比较一个'\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