Please provide answer in C/C++ 01h:28m to test enc Cisco XR SW Dev 1T 0/2 Attemp
ID: 3915747 • Letter: P
Question
Please provide answer in C/C++
01h:28m to test enc Cisco XR SW Dev 1T 0/2 Attempted Pranjal Srivas Explanation 0 Given a [4,3, 571 and b 12, 4, 49), we'll call our return array value. Julia finds the following n 3 solutions: 0. Non-negative solution (x, y) for the following equations: There exists a solution (x, y) - (1, 3) because 1 + 3 4 and 1 3 2. So, valueo 2x+ 3y 2 x1+3 x3 11. 1. Non-negative solution (x, y) for the following equations: No valid solution exists, so value 0. 2. Non-negative solution (x, y) for the following equations: There exists a solution (x, y) 14, 53) because 4 + 53-57 and 4 e 53-49. so, value. 2-3y-2x 4 + 3 , 5)-161 Thus, we return value- [11, 0, 167! as our answe YOUR ANSWERExplanation / Answer
ScreenShot
---------------------------------------------------
Program
//header file
#include<iostream>
using namespace std;
//Main method to test
int main()
{
//Variables for number of elements and arrays
int n;
int a[50], b[50], res[50] = { 0 };
int i=0,val=0,x=0,y=0;
//Prompt for array
cout << "Enter the number of elements in array:";
cin >> n;
//Check constraints
while (!n>=1 && !n<=50) {
cout << "Enter the number of elements in array:";
cin >> n;
}
//a array
cout << "enter a array values" << endl;
for (i = 0; i < n; i++) {
cin >> val;
if(val>=1)
a[i]=val;
}
//b array
cout << "enter b array values" << endl;
for (i = 0; i < n; i++) {
cin >> b[i];
}
//Loop to generate solution
for (int i = 0; i<n; i++) {
x = 0;
y = a[i];
while (x < y) {
if (x | y == a[i]) {
if (x^y == b[i]) {
res[i] = (2 * x) + (3 * y);
break;
}
}
x++;;
y--;;
}
}
//result display
for (i = 0; i < n; i++) {
cout << res[i] << " " << endl;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.