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

Faint...WA ing,附代码,请大家帮忙. Thx

Posted by qdj_dlut_faye at 2008-12-04 09:47:46 on Problem 1573
#include <iostream>
using namespace std; 

const int size=10;
char c[size][size];
int a[size][size];
int row,col,st,steps;

int main()
{
    while(cin>>row>>col>>st&&row)
    {
        steps=0;
        memset(c,0,sizeof(c));
        memset(a,0,sizeof(a));
        for(int i=0;i<row;i++)
        for(int j=0;j<col;j++)
        cin>>c[i][j];
        
        int tmprow=0,tmpcol=st-1;
        char  temp;
        while(!(tmprow<0||tmpcol<0)&&!(a[tmprow][tmpcol]))
        {
             steps++;
            a[tmprow][tmpcol]=steps;
            temp=c[tmprow][tmpcol];
           
            switch(temp)
            {
                case 'N': tmprow--;break;
                case 'S': tmprow++;break;
                case 'E': tmpcol++;break;
                case 'W': tmpcol--;break;
            }
            
        }
        
        if(tmprow<0||tmpcol<0||tmprow>=row||tmpcol>=col)
        cout<<steps<<" step(s) to exit"<<endl;
        else
        {
            cout<<a[tmprow][tmpcol]-1<<" step(s) before a loop of "<<steps-a[tmprow][tmpcol]+1<<" step(s)"<<endl;
        }
        
     
    }
    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