| ||||||||||
| 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 | |||||||||
Re:谁解析下, 这两个循环到底怎么不一样?In Reply To:谁解析下, 这两个循环到底怎么不一样? Posted by:twf at 2008-02-26 14:09:44 > for (int s = 0; s < V; s++)
> for (int t = 0; t < V; t++)
> {
> if (s == t) continue;
> for (int i = 0; i < V; i++)
> {
> if (dist[s][i] + dist[i][t] < dist[s][t])
> dist[s][t] = dist[s][i] + dist[i][t];
> }
> }
>
>
>
>
>
> for (int i = 0; i < V; i++) //中间点应该在最内层循环枚举
> for (int s = 0; s < V; s++)
> for (int t = 0; t < V; t++)
> if (s != t)
> if (dist[s][t] > dist[s][i] + dist[i][t])
> dist[s][t] = dist[s][i] + dist[i][t];
>
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator