Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Targil24
- {
- public static String smarty(String tamlilim)
- {
- int i=0,WordsCount=0,d=0;
- String newstr="",temp="";
- tamlilim=tamlilim+" ";
- while(i<=tamlilim.length()-1)
- {
- if(tamlilim.charAt(i)==' ')
- WordsCount++;
- i++;
- }
- String [] str = new String[WordsCount+1];
- i=0;
- while(i<=tamlilim.length()-1)
- {
- if(tamlilim.charAt(i)==' ')
- {
- str[d]=temp;
- temp="";
- d++;
- }
- else
- {
- temp=temp+tamlilim.charAt(i);
- }
- i++;
- }
- for(i=0;i<WordsCount;i++)
- {
- if(str[i].equals(str[i+1])==false)
- newstr=newstr+str[i]+" ";
- }
- return newstr;
- }
- {
- }
- static Scanner reader=new Scanner(System.in);
- public static void main(String[] args)
- {
- Scanner in= new Scanner (System.in);
- String a;
- System.out.println("הכנס משפט:");
- a=in.nextLine();
- System.out.print(smarty(a));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement