Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. import java.lang.String;
  2. import java.util.*;
  3. class test{
  4.     public static int Search(String [] s, String toFind,int size){
  5.         for(int i = 0 ; i < size ; i++){
  6.             if(s[i].equals(toFind)){
  7.                 return i;
  8.             }
  9.         }
  10.         return -1;
  11.     }
  12.     public static void main(String [] arg){
  13.         Scanner sc = new Scanner(System.in);
  14.         String line = sc.nextLine();
  15.         StringTokenizer TK =  new StringTokenizer(line);
  16.         int i = 0;
  17.         String[] words = new String[50];
  18.         int[] count = new int[50];
  19.         while(TK.hasMoreTokens()){
  20.             words[i]=TK.nextToken();
  21.             count[i++]++;
  22.         }
  23.         for(int j = 0 ; j < i; j++){
  24.         int s = Search(words,words[j],i);
  25.             if(s!=-1)
  26.                 a[s]++;
  27.                 else
  28.                
  29.            
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement