Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner in = null;
- in = new Scanner(System.in);
- String stroka;//=" ";
- System.out.println("Введите строки ");
- while(in.hasNextLine()) {
- int flag=0;
- stroka = in.nextLine();
- int length = stroka.length();
- for (int i = 0; i < length; ++i) {
- if((Character.isDigit(stroka.charAt(i))||stroka.charAt(i)=='.')==false)
- flag=0;
- if((Character.isDigit(stroka.charAt(i))||stroka.charAt(i)=='.')&&flag==0) {
- if(stroka.charAt(i)!='0') {
- flag=1;
- }
- if(i==length-1)
- break;
- if(stroka.charAt(i+1)=='.')
- flag=1;
- if(Character.isDigit(stroka.charAt(i+1))==false)
- flag=1;
- if(stroka.charAt(i)=='0'&&flag==0) {
- stroka=stroka.substring(0,i)+stroka.substring(i+1,length);
- --i;
- --length;
- }
- }
- }
- System.out.println(stroka);
- }
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement