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]
4 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]4 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
Giving out 100 coins cuz why not?​
inysia [295]

Answer:

HI

Explanation:

7 0
3 years ago
kg is moving at a speed of 40 km/h on an incline of 1 in 50. The total constant rolling and wind resistance is 600 N. The effici
frozen [14]

Answer:

significa pene + cuca rico

Explanation:

7 0
3 years ago
What is the magnitude of the maximum stress that exists at the tip of an internal crack having a radius of curvature of 2.5×10-4
krok68 [10]

Answer:

1788.9 MPa

Explanation:

The magnitude of the maximum stress (σ) can be calculated usign the following equation:

\sigma = 2\sigma_{0} \sqrt{\frac{a}{\rho}}

<u>Where:</u>

<em>ρ: is the radius of curvature = 2.5x10⁻⁴ mm (0.9843x10⁻⁵ in)</em>

<em>σ₀: is the tensile stress = 100x10⁶ Pa (14500 psi) </em>

<em>2a: is the crack length = 4x10⁻² mm (1.575x10⁻³ in) </em>

Hence, the  maximum stress (σ) is:

\sigma = 2*100\cdot 10^{6} Pa \sqrt{\frac{(4 \cdot 10^{-2} mm)/2}{2.5 \cdot 10^{-4} mm}} = 1.79 \cdot 10^{6} Pa = 1788.9 MPa    

Therefore, the magnitude of the maximum stress is 1788.9 MPa.

I hope it helps you!

5 0
4 years ago
A homogeneous 800kg bar AB is supported at either end by a cable asshown in the figure
aleksandr82 [10.1K]

The smallest area of each cable if the stress is not to exceed 90MPa in bronze is 43.6 mm² and 120MPa in steel is 32.7 mm².

<h3>What is normal stress?</h3>

If the direction of deformation force is perpendicular to the cross-sectional area of ​​the body, the stress is called normal stress. Changes in wire length and body volume will be normal.

σ = P/A

Where, σ = Normal stress

P = Pressure

A = Area

1 Kg = 9.81 N

800 kg = 7848 N

Since the rod is half bronze and half steel

800 kg = 7848/2

= 3924 N

Pₙ = Fₙ = 3924 N                       [n = Bronze]

Pₓ =  3924 N                             [x = steel]

Given,

σₙ = 90MPa

σₓ = 120MPa

Aₙ = ?

Aₓ = ?

Aₙ = Pₙ/σₙ

Aₙ = 3924/90

Aₙ = 43.6 mm²

Aₓ = Pₓ/σₓ

Aₓ = 3924/120

Aₓ = 32.7 mm²

To know more about normal stress, visit:

brainly.com/question/28012990

#SPJ9

4 0
1 year ago
What is clearance? What is backlash? What is interference? Explain briefly.
Anton [14]

Explanation:

Clearance:

For easy matching  and dis matching  of  hole and  shaft we use size of hole little bit more than the size of shaft and this difference in size is called clearance.

Backlash:

  It is the clearance between the two mating gear to avoids failure of gears.Actually when temperature of gears increases then at the same time the size of gear also increases ,due this there is a possibility foe jamming of gears so to avoids this backlash is provides.

Interference:

  When two gears are matting then addendum of one gear inters into the deddendum of another gear and due to this gears get jam .This phenomenon is called interference.

5 0
3 years ago
Other questions:
  • Check pics to help me out on a pennfoster exam. Will mark brainliest if I pass the test. Thanks a lot.
    7·1 answer
  • Whats better Chevrolet or Ford
    12·2 answers
  • Name one challenge for engineering managers wanting to implement the concurrent engineering concept
    12·1 answer
  • At steady state, a valve and steam turbine operate in series. The steam flowing through the valve undergoes a throttling process
    9·1 answer
  • Define construction document​
    5·1 answer
  • Draw a sinusoidal signal and illustrate how quantization and sampling is handled by
    8·1 answer
  • What are examples of Quality Assurance workplaces? Check all that apply.
    12·2 answers
  • What are the two tools used to create an HTML code? Name one example of each tool.
    9·1 answer
  • Omg I just got 17/25 questions wrong using this on an Ag test , but got 100’s every time on health
    6·2 answers
  • when the filament breaks in one lamp in a series circuit, other lamps in the circuit normally _________.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!