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

有谁能解释下下面两种写法到底有什么不同,为什么法1WA,法2AC(C++语法问题)

Posted by songxuehui at 2010-03-03 20:06:39 on Problem 2251
法1:
void findStart(int &x, int &y, int &z) {
    for(x = 0; x < L; x ++) {
        for(y = 0; y < R; y ++) {
            for(z = 0; z < C; z ++) {
                if(a[x][y][x] == 'S') {
                    return ;
                }
            }
        }
    }
}
int x, y, z;
findStart(x, y, z);
法2:
int x, y, z;
for(int i = 0; i < L; i ++) {
    for(int j = 0; j < R; j ++) {
         for(int k = 0; k < C; k ++) {
              if(a[i][j][k] == 'S') {
                   x = i, y = j, z = k;
               }
          }
      }
 }
这两种方法得到的x、y、z到底有什么不同?

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