Problem Description
A piece of flower cloth, there are some patterns, there is a directly available small bar, there are some patterns. For a given strip of flowers and strips, calculate how many pieces of strips can be cut from the flower cloth?
Input
The input contains some data, respectively, is a pair of flowers and small strips, the cloth is shown with visible ASCII characters, the number of visible ASCII characters, the pattern of the cloth is also how many kinds of patterns. The strips and strips are not more than 1000 characters in length. If you meet the # character, you are no longer working.
Output
Output can be cut from the pattern cloth up to the number of small strips, if not a piece, then honestly output 0, each result should be wrapped.
Sample Input
ABCDE A3
AAAAAA AA
#
Sample Output
0
3
Flood problem!
Java with indexof () method seconds past ~
ImportJava.util.Scanner;/** * @author Chen Haoxiang * @version 1.0 2016-6-2 * * Public class Main{ Public Static void Main(string[] args) {Scanner SC =NewScanner (system.in); while(Sc.hasnext ()) {String str =sc.next ();if(Str.equals ("#")){return; } String A = Sc.next ();intsum=0;intI=0;intt=0; while(true){if(t==0) {I=str.indexof (A, I); t=1; }Else{I=str.indexof (A, i+a.length ()); }if(i==-1){ Break; } sum++; } System.out.println (sum); } }}
Hdoj/hdu 2087 Cut Cloth (indexOf () application ~ ~)