| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
那么多人过了,本来不该怀疑数据问题,可是我的程序明显显示出,数据好像有问题,内详...我的程序老是runtime error.经过我逐条试验,发现数据可能会出现这种情况:
person_id child_1 child_2 gender
其中并child_1没有相应的描述他的数据。感觉非常奇怪。
贴出程序片断,不含核心(请管理员莫怪)
while (true)
{
s = cin.readLine();
if (s == null)
break;
s = s.trim();
sa = s.split(" +");
int id = Integer.parseInt(sa[0]);
Person p = new Person(id, Integer.parseInt(sa[sa.length - 1]));
all.put(id, p);
childs.put(id, new ArrayList<Integer>());
if (sa.length > 2)
{
for (int i = 1; i < sa.length - 1; i++)
childs.get(id).add(Integer.parseInt(sa[i]));
}
}
for (Integer id : all.keySet())
{
List<Integer> cs = childs.get(id);
Person p = all.get(id);
for (int i = 0; i < cs.size(); i++)
{
Person cp = all.get(cs.get(i));
//******** 此处cp有可能为null,所以怀疑数据
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator