福建师范大学1770(B)

福建师范大学1770(B)
http://acm.fjnu.edu.cn/show?problem_id=1770
import  java.util. * ;
import  java.io. * ;

public   class  ACM_1770 {
    
    
public static void main(String rgs[]) throws Exception
    
{
        BufferedReader stdin 
= 
            
new BufferedReader(
                
new InputStreamReader(System.in));
        String line 
= stdin.readLine(); 
        
int i,j,n = Integer.parseInt(line); 
        String[] s
=new String[n+1];
        
int[] a=new int[n+1];
        
int count=0;
        Arrays.fill(a,
0);
        
for(i=1;i<=n;i++)
            s[i] 
= stdin.readLine();
        i
=1;
        
while(true){
            StringTokenizer st 
= new StringTokenizer(s[i]);
            String t
=st.nextToken();
            
if(a[i]==1){
                count
=0;
                
break;
            }

            a[i]
=1;
            count
++;
            
if(t.equals("jmp")){
                j
=Integer.parseInt(st.nextToken());
                i
=j;
                
continue;
            }

            i
++;                
            
if(i>n)
                
break;
        }

        System.out.println(count);
    }

}

你可能感兴趣的:(福建师范大学1770(B))