You are given two arrays of integers a and b of the same length, and an integer k . We will be iterating through array a from left to right, and simultaneously through array b from right to left, and looking at pairs (x, y), where x is from a and y is from b Such a pair is called tiny if the concatenation xy is strictly less than k. Your task is to return the number of tiny pairs that you'll encounter during the simultaneous iteration through a and b.

Respuesta :

Answer:

#include <iostream>

using namespace std;

int main(){

   int arr1[5], arr2[5], k = 7;

   arr1 = {1,3,5,3,6}

   arr2 = {1,3,2,4,4}

   int reverseA2[5];

   for (int x = 5; x > 0; x++){

       reverseA2[5-x] = arr2[x-1];

   }

   for (int i = 0; i < 5; i++){

       if ( arr1[i] + reverseA2[i] < k){

           cout<< arr1[i] << " , "<<reverseA2[i];

       }

   }

}

Explanation:

The C++ source code prints a pair of values from the arr1 and reverse arr2 arrays whose sum is less than the value of the integer variable value k.

Iterating through an array requires the use of loops.

The function in C++ where comments are used to explain each line is as follows:

//This defines the function that checks for tiny pairs

void pairs(int []a,int []b,n,k){

//This iterates through the arrays; array a, in ascending order, and b in reversed order

   for (int i = 0; i < n; i++){

//This checks for tiny pair

       if ( a[i] + b[n-i] < k){

//If yes, the pairs are printed

           cout<< a[i] << ","<<b[n-i]<<'\n';

       }

   }

}

Read more about loops at:

https://brainly.com/question/19344465