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
can anyone help me with this please.i have the current and pf for branch 1 and 2 but cant figure out the total current, pf and a
anyanavicka [17]

Answer:

  • branch 1: i = 25.440∠-32.005°; pf = 0.848 lagging
  • branch 2: i = 21.466∠63.435°; pf = 0.447 leading
  • total: i = 31.693∠10.392° leading; pf = 0.984 leading

Explanation:

To calculate the currents in the parallel branches, we need to know the impedance of each branch. That will be the sum of the resistance and reactance.

The inductive reactance is ...

  X_L=j\omega L=j2\pi fL=j100\pi\cdot 15.915\times10^{-3}\approx j4.99984\,\Omega

The capacitive reactance is ...

  X_C=\dfrac{1}{j\omega C}=\dfrac{-j}{100\pi\cdot 318.31\times10^{-6}F}\approx -j10.00000\,\Omega

<u>Branch 1</u>

The impedance of branch 1 is ...

  Z1 = 8 +j4.99984 Ω

so the current is ...

  I1 = V/Z = 240/(8 +j4.99984) ≈ 25.440∠-32.005°

The power factor is cos(-32.005°) ≈ 0.848 (lagging)

<u>Branch 2</u>

The impedance of branch 2 is ...

  Z2 = 5 -j10 Ω

so the current is ...

  I2 = 240/(5 +j10) ≈ 21.466∠63.435°

The power factor is cos(63.436°) ≈ 0.447 (leading)

<u>Total current</u>

The total current is the sum of the branch currents. A suitable calculator can add these vectors without first converting them to rectangular form.

  It = I1 +I2 = (21.573 -j13.483) +(9.6 +j19.2)

  It ≈ 31.173 +j5.717 ≈ 31.693∠10.392°

The power factor for the circuit is cos(10.392°) ≈ 0.984 (leading)

__

The phasor diagram of the currents is attached.

_____

<em>Additional comment</em>

Given two vectors, their sum can be computed several ways. One way to compute the sum is to use the Law of Cosines. In this application, the angle between the vectors is the supplement of the difference of the vector angles: 84.560°.

3 0
2 years ago
Good night. I need to go to bed. Byeeeeeeeeeeeee.​
dimaraw [331]

Answer:

BYEEEEEEEEEEEE3EEEEEEEEEE

Explanation:

dawg

8 0
3 years ago
What do u call a bad bird
statuscvo [17]

Answer:

A buzzerd

Explanation:

4 0
2 years ago
For a cylindrical annulus whose inner and outer surfaces are maintained at 30 ºC and 40 ºC, respectively, a heat flux sensor mea
miskamm [114]

Answer:

k=0.12\ln(r_2/r_1)\frac {W}{ m^{\circ} C}

where r_1 and r_2 be the inner radius, outer radius of the annalus.

Explanation:

Let r_1, r_2 and L be the inner radius, outer radius and length of the given annulus.

Temperatures at the inner surface, T_1=30^{\circ}C\\ and at the outer surface, T_2=40^{\circ}C.

Let q be the rate of heat transfer at the steady-state.

Given that, the heat flux at r=3cm=0.03m is

40 W/m^2.

\Rightarrow \frac{q}{(2\pi\times0.03\times L)}=40

\Rightarrow q=2.4\pi L \;W

This heat transfer is same for any radial position in the annalus.

Here, heat transfer is taking placfenly in radial direction, so this is case of one dimentional conduction, hence Fourier's law of conduction is applicable.

Now, according to Fourier's law:

q=-kA\frac{dT}{dr}\;\cdots(i)

where,

K=Thermal conductivity of the material.

T= temperature at any radial distance r.

A=Area through which heat transfer is taking place.

Here, A=2\pi rL\;\cdots(ii)

Variation of temperature w.r.t the radius of the annalus is

\frac {T-T_1}{T_2-T_1}=\frac{\ln(r/r_1)}{\ln(r_2/r_1)}

\Rightarrow \frac{dT}{dr}=\frac{T_2-T_1}{\ln(r_2/r_1)}\times \frac{1}{r}\;\cdots(iii)

Putting the values from the equations (ii) and (iii) in the equation (i), we have

q=\frac{2\pi kL(T_1-T_2)}{\LN(R_2/2_1)}

\Rightarrow k= \frac{q\ln(r_2/r_1)}{2\pi L(T_2-T_1)}

\Rightarrow k=\frac{(2.4\pi L)\ln(r_2/r_1)}{2\pi L(10)} [as q=2.4\pi L, and T_2-T_1=10 ^{\circ}C]

\Rightarrow k=0.12\ln(r_2/r_1)\frac {W}{ m^{\circ} C}

This is the required expression of k. By putting the value of inner and outer radii, the thermal conductivity of the material can be determined.

7 0
3 years ago
An Ideal gas is being heated in a circular duct as while flowing over an electric heater of 130 kW. The diameter of duct is 500
max2010maxim [7]

Answer: The exit temperature of the gas in deg C is 32^{o}C.

Explanation:

The given data is as follows.

C_{p} = 1000 J/kg K,   R = 500 J/kg K = 0.5 kJ/kg K (as 1 kJ = 1000 J)

P_{1} = 100 kPa,     V_{1} = 15 m^{3}/s

T_{1} = 27^{o}C = (27 + 273) K = 300 K

We know that for an ideal gas the mass flow rate will be calculated as follows.

     P_{1}V_{1} = mRT_{1}

or,         m = \frac{P_{1}V_{1}}{RT_{1}}

                = \frac{100 \times 15}{0.5 \times 300}

                = 10 kg/s

Now, according to the steady flow energy equation:

mh_{1} + Q = mh_{2} + W

h_{1} + \frac{Q}{m} = h_{2} + \frac{W}{m}

C_{p}T_{1} - \frac{80}{10} = C_{p}T_{2} - \frac{130}{10}

(T_{2} - T_{1})C_{p} = \frac{130 - 80}{10}

(T_{2} - T_{1}) = 5 K

T_{2} = 5 K + 300 K

T_{2} = 305 K

           = (305 K - 273 K)

           = 32^{o}C

Therefore, we can conclude that the exit temperature of the gas in deg C is 32^{o}C.

7 0
3 years ago
Other questions:
  • A 2"" Sch 40 stainless steel (k = 14.9 W/m-K) pipe is to be used as the interior pipe of a double pipe heat exchanger. The expec
    6·1 answer
  • In order to build a skyscraper Builders, Inc. hires 400 construction workers and 50 managers. Builders, Inc. represents A entrep
    8·1 answer
  • How can endurance athletes best delay muscle fatigue during training? a. By avoiding sports drinks during exercise b. By eating
    6·2 answers
  • The motion of a particle is defined by the relation x = t3 – 6t2 + 9t + 3, where x and t are expressed in feet and seconds, resp
    12·1 answer
  • Which source would be the best to base a hypothesis upon
    9·1 answer
  • By using a book of the OHS Act, Act 85 of 1993, find the act or regulation where the following extraction comes from "every empl
    12·1 answer
  • prove that the heat transfer at the constant pressure is given by the enthalpy change during the process​
    7·1 answer
  • A team of engineers is working on a design to increase the power of a hydraulic lever. They have brainstormed several ideas. Whi
    13·1 answer
  • fdkgdsvdgvdfgvsdcvbfbfdbvfdbsdvbesgvdslgfkrledmgoskflodjgloerjgvoljgegjp;erorf;wgp;kiaers;ogjo;rhgerjfrejgfdlhodjglodjheihtgo;rg
    13·1 answer
  • Describe the greatest power in design according to Aravena?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!