Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const getGets = (arr) => {
- let index = 0;
- return () => {
- const toReturn = arr[index];
- index += 1;
- return toReturn;
- };
- };
- // This is the place where you must place your test data
- const test = [
- '8', // This is the first line from the test.
- '2 4 6 2 4 1 2 3 5 9', // This is the second line from the test.
- ];
- const gets = this.gets || getGets(test);
- const print = this.print || console.log;
- // Solution of the problem. zad2 Pairs 100/100
- let n = Number(gets());
- let array = gets().split(" ").map(Number);
- let arr2 = [];
- for (i = 0; i < array.length; i++) {
- for (y = 0; y < array.length; y++) {
- if ((y > i) && (array[i] + array[y] === n)) {
- arr2.push(array[i], array[y]);
- }
- }
- }
- if (arr2.length == 0) {
- console.log("no pairs");
- } else
- for (z = 0; z < arr2.length; z = z + 2) {
- console.log(`${arr2[z]},${arr2[z + 1]}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement