Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.util.stream.Collectors;
- public class delenieBezOstatuk {
- public static void main(String[]args){
- Scanner scanner = new Scanner(System.in);
- List<Integer> sequenceOfNumbers = new ArrayList<>();
- String[] array = scanner.nextLine().split((" "));
- String otherArray = scanner.nextLine();
- String[] message = new String[otherArray.length()];
- for (int i = 0; i < array.length; i++) {
- sequenceOfNumbers.add(Integer.parseInt(array[i]));
- }
- List<String> word = new ArrayList<>();
- int sum4e = 0;
- for (int i = 0; i < sequenceOfNumbers.size(); i++) {
- int num = sequenceOfNumbers.get(i);
- while (!(num==0)){
- sum4e += num%10;
- num /= 10;
- }
- sequenceOfNumbers.remove(sequenceOfNumbers.get(i));
- i=0;
- if (sum4e>message.length){
- for (int j = 0; j < message.length; j++) {
- if (message.length+j==sum4e){
- word.add(String.valueOf(message[message.length+j]));
- }
- }
- }
- else{
- for (int j = 0; j < message.length; j++) {
- if (j==sum4e){
- word.add(String.valueOf(message[j]));
- }
- }
- }
- }
- String output = String.join("",word);
- System.out.println(output);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement