1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
trapecia [35]
3 years ago
14

Your program should read from an input file, which will contain one or more test cases. Each test case consists of one line cont

aining two squares separated by one space. A square is a string consisting of a letter (a-h) representing the column and a digit (1-8) representing the row on the chessboard.
Engineering
1 answer:
Aliun [14]3 years ago
3 0

Answer:

#include <bits/stdc++.h>

using namespace std;

struct cell

{

int x, y;

int dis;

cell() {}

cell(int x, int y, int dis) : x(x), y(y), dis(dis) {}

};

bool isInside(int x, int y, int N)

{

if (x >= 1 && x <= N && y >= 1 && y <= N)

return true;

return false;

}

int minStepToReachTarget(int knightPos[], int targetPos[],

int N)

{

int dx[] = {-2, -1, 1, 2, -2, -1, 1, 2};

int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};

queue<cell> q;

q.push(cell(knightPos[0], knightPos[1], 0));

cell t;

int x, y;

bool visit[N + 1][N + 1];

for (int i = 1; i <= N; i++)

for (int j = 1; j <= N; j++)

visit[i][j] = false;

visit[knightPos[0]][knightPos[1]] = true;

while (!q.empty())

{

t = q.front();

q.pop();

visit[t.x][t.y] = true;

if (t.x == targetPos[0] && t.y == targetPos[1])

return t.dis;

for (int i = 0; i < 8; i++)

{

x = t.x + dx[i];

y = t.y + dy[i];

if (isInside(x, y, N) && !visit[x][y])

q.push(cell(x, y, t.dis + 1));

}

}

}

int main(){

ifstream obj("input.txt");

string line;

int x1,y1,x2,y2;

while(getline(obj,line)){

//cout<<line<<endl;

x1=line[0]-'a'+1;

y1=line[1]-'0';

x2=line[3]-'a'+1;

y2=line[4]-'0';

int N = 8;

int knightPos[] = {x1,y1};

int targetPos[] = {x2,y2};

cout <<"To get from "<<line[0]<<line[1]<<" to "<<line[3]<<line[4]<<" takes "<< minStepToReachTarget(knightPos, targetPos, N)<<" Knight Moves."<<endl;

}

return 0;

}

You might be interested in
Technician A says that hoods are designed with reinforcements to prevent folding during a collision. Technician B says that some
-BARSIC- [3]

Technician A is wrong.

  • Usually, hoods have what is called "Crush Zones" underneath the panels. The function of the Crush Zone is to prevent the hoods, during a collision, from entering into the passenger space.

  • The crush zones allow the hoods to fold instead.

Technician B is right.

  • Automobile producers now make use of a hybrid form of hood that consists of fiberglass reinforced with plastic.

  • They are mostly used for trucks that have a low volume of production.

  • The hood is built using a process called Resin Transfer Model (RTM).

See the link below for more about automobile engineering:

brainly.com/question/4822721

6 0
2 years ago
A house is losing heat at a rate of 1700 kJ/h per °C temperature difference between the indoor and the outdoor temperatures. Exp
Furkat [3]

Answer:

1700kJ/h.K

944.4kJ/h.R

944.4kJ/h.°F

Explanation:

Conversions for different temperature units are below:

1K = 1°C + 273K

1R = T(K) * 1.8

= (1°C + 273) * 1.8

1°F = (1°C * 1.8) + 32

Q/delta T = 1700kJ/h.°C

T (K) = 1700kJ/h.°C

= 1700kJ/K

T (R) = 1700kJ/h.°C

= 1700kJ/h.°C * 1°C/1.8R

= 944.4kJ/h.R

T (°F) = 1700kJ/h.°C

= 1700kJ/h.°C * 1°C/1.8°F

= 944.4kJ/h.°F

Note that arithmetic operations like subtraction and addition of values do not change or affect the value of a change in temperature (delta T) hence, the arithmetic operations are not reflected in the conversion. Illustration: 5°C - 3°C

= 2°C

(273+5) - (273+3)

= 2 K

5 0
3 years ago
Which is a feedback mechanism for a system?
stira [4]

The following is a feedback mechanism for a system :

<u>The progress bar when downloading a file on iTunes</u>

<u></u>

Explanation:

  • A feedback mechanism is a loop system wherein the system responds to a perturbation. The response may be in the same direction (as in positive feedback) or in the opposite direction (as in negative feedback).
  • Feedback occurs when outputs of a system are routed back as inputs as part of a chain of cause-and-effect that forms a circuit or loop. The system can then be said to feed back into itself.
  • Evaluation feedback needs to be done “in the moment” to help the person receiving the feedback know where they stand.
  • A feedback control system consists of five basic components: (1) input, (2) process being controlled, (3) output, (4) sensing elements, and (5) controller and actuating devices.
  • Because negative feedback produces stable circuit responses, improves stability and increases the operating bandwidth of a given system, the majority of all control and feedback systems is degenerative reducing the effects of the gain.

6 0
3 years ago
Technician A says that the original equipment manufacturer (OEM) offer scan tools to service their specific line of vehicles. Te
Anastasy [175]

Answer:

a. Technician A

Explanation:

Aftermarket parts are replacement parts that are not made by the original equipment manufacturer. They can not guarantee as much functionaluty when compared to OEMs. Original Equipment Manufacturer (OEM) usually their own proprietary scan tools which offer better and functionality to service their special line of vehicles. So Technician A alone is correct.

8 0
3 years ago
Read 2 more answers
How can you avoid aliasing error during sampling when converting an analog signal?
Romashka-Z-Leto [24]

Answer and Explanation:

Aliasing is a distortion in the signal when a continuous signal is converted into digital signal that is ADC process, due to this effect the signal aliases of one another.There will be no aliasing effect if the frequency of the signal will not be higher than the sampling frequency

The another way of avoiding aliasing is to limit the range of the continuous signal.

7 0
3 years ago
Other questions:
  • 12. The small space above the piston in which fuel is burned is called the
    10·1 answer
  • Design a PI controller to improve the steady-state error. The system should operate with a damping ratio of 0.8. Compute the ove
    10·1 answer
  • Please answer the following questions.
    9·2 answers
  • Steam flows steadily through an adiabatic turbine. The inlet conditions of the steam are 10 MPa, 450°C, and 80 m/s, and the exit
    11·1 answer
  • The Hubble Space Telescope is an optical imaging telescope with extremely good angular resolution. Someone discovers an object t
    13·1 answer
  • How to update android 4.4.2 to 5.1 if there isnt any update available​
    15·2 answers
  • In order to fill a tank of 1000 liter volume to a pressure of 10 atm at 298K, an 11.5Kg of the gas is required. How many moles o
    11·1 answer
  • Two sites are being considered for wind power generation. On the first site, the wind blows steadily at 7 m/s for 3000 hours per
    5·1 answer
  • ⚠️I mark BRIANLIST ⚠️The same engineering teams are able to design and develop the different subsystems for an airplane.
    5·2 answers
  • Write a statement that calls the recursive method backwardsAlphabet() with parameter startingLetter.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!