SHARE
TWEET

Untitled

a guest Feb 23rd, 2020 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner input = new Scanner(System.in);
  10.         String zodis, dummy;
  11.         int ilgis;
  12.  
  13.         System.out.println("Iveskite norimos eilutes ilgi: ");
  14.         String EilutesIlgis = input.nextLine();
  15.         int max = Integer.parseInt(EilutesIlgis);
  16.         System.out.println(max);
  17.  
  18.         System.out.println("Iveskite eilute: ");
  19.         StringBuffer eilute = new StringBuffer();
  20.         dummy = input.nextLine();
  21.         input.close();
  22.         eilute.append(dummy);
  23.  
  24.         for(int i = 0; i < eilute.length(); i++){
  25.             if(eilute.charAt(i) == ' '){
  26.                 while(eilute.charAt(i+1) == ' '){
  27.                     eilute.deleteCharAt(i+1);
  28.                 }
  29.             }
  30.         }
  31.         int pointer = 0;
  32.  
  33.         for(int i = 0; i < eilute.length(); i++){
  34.             if(pointer == max){
  35.                 eilute.insert(i, '\n');
  36.                 pointer = -1;
  37.             }
  38.             pointer++;
  39.         }
  40.         System.out.println(eilute);
  41.     }
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top