Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ContaDoppie {
- public static void main(String[] args) {
- char[] A = {'a','b','a','a','b','c','c','c','a','a','b','a','c'};
- int i=0;
- int f=A.length-1;
- int ris=conta(A,i,f);
- System.out.println("Le coppie di caratteri nell'array precaricato sono: " + ris);
- }
- public static int conta(char A[],int i, int f){
- int S;
- if (i==f)
- return(0);
- else{
- int m=((i+f)/2);
- int C=conta(A,i,m);
- int D=conta(A,m+1,f);
- S=C+D;
- if (A[m]==A[m+1])
- S++;
- }
- return(S);
- }
- }
Add Comment
Please, Sign In to add comment