Poj Solution 3753

http://poj.org/problem?id=3753

import java.io.BufferedInputStream;   
import java.util.Scanner;   
  
/**  
 *  
 *poj3753  
 * C�������  
 * while(EOF != scanf("%s",source))  
 *�ȼ���java���while (scan.hasNext())  
 * @author NC  
 */  
public class Main {   
  
    public static void main(String[] args) {   
        Scanner scan = new Scanner(new BufferedInputStream(System.in));   
        while (scan.hasNext()) {   
            String src = scan.nextLine().trim();   
            while (true) {   
                String key = scan.nextLine().trim();   
                if (key.endsWith("END")) {   
                    break;   
                }   
                if (key.equals("NULL")) {   
                    System.out.println("0 NULL");//�ݾ�   
                } else if (key.isEmpty() || key.equals("") || !src.contains(key)) {   
                    System.out.println(src.length() + " " + src);//�ݾ�   
                } else if (src.contains(key)) {   
                    String sub = src.substring(0, src.indexOf(key));   
                    if (src.indexOf(key) == 0) {   
                        System.out.println("0 NULL");//�ݾ�   
                    } else {   
                        System.out.println(sub.length() + " " + sub);   
                    }   
                }   
            }   
        }   
    }   
}  


											
This entry was posted in poj. Bookmark the permalink.