Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class charMethods {
- public static void main(String [] args){
- char [] betuk = {'a','e','m','a','z','i','u','u','u','i','o'};
- //System.out.println(elofordul("uzi", betuk));
- //howMany(betuk); // 6
- System.out.println(tavolsag('a','i',betuk));
- }
- /*static void howMany(char [] chars){
- char [] tmp = new char [chars.length];
- int n=0;
- for(int i=0; i<chars.length; i++)
- for(int j=0; j<tmp.length; j++)
- if(tmp[j] == chars[i]) {
- break;
- }
- else {
- tmp[n++] = chars[i];
- break;
- }
- for(int i=0; i<tmp.length; i++)
- System.out.println(tmp[i] + ": ");
- }*/
- /*static boolean elofordul(String szo, char[] chars){
- boolean tmp [] = new boolean [szo.length()];
- int n=0;
- boolean ered = false;
- for(int i=0; i<chars.length; i++)
- for(int j=0; j<szo.length(); j++)
- if( chars[i]==szo.charAt(j) )
- tmp[n++] = true;
- for(int i=0; i<tmp.length; i++)
- if(tmp[i] == false)
- ered = false;
- return ered;
- }*/
- static int tavolsag(char a, char b, char [] array){
- int aHely = 0;
- int bHely = 0;
- for(int i=0; i<array.length; i++)
- if(array[i] == a){
- aHely = i;
- break;
- }
- for(int i=aHely; i<array.length; i++)
- if(array[i] == b){
- bHely = i;
- break;
- }
- return bHely-aHely;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment