Advertisement
flomath

findesubarray

Feb 5th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. public static boolean findeSubarray2( int[] werte, int[] subarray){
  2.         if(werte.length<subarray.length)return false;
  3.         int c=0;
  4.         for(int k=0; k<=werte.length-subarray.length;k++){
  5.             c=0;
  6.             for( int j =0; j<subarray.length; j++){
  7.                 if(werte[k+j]==subarray[j]){
  8.                     c++;
  9.                     if(c==subarray.length) return true;
  10.                 }
  11.                 else break;
  12.                 }
  13.             }
  14.         return false;
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement