+ 1

[C++]Code for outputting maze

Hi, I'm in final year of High School and IT university I want to study (the best one in my country) has made a programming tasks, so I'll be probably posting here a few tasks so you can learn with me and I'll also ask you for help. The first task is, the shortest path from the start to the end of maze has exact length. Start is at the upper left-hand corner and end is at the bottom right-hand corner. You can move only on neighbourhood square that shares with your actual square full side. Let's call the moving object warden. You have to make maze for every warden. Input explanation: In the first line is one integer 1<= t <= 1000. t........number of wardens Then follows t lines (that means one maze for each warden) Each line contains 3 integers m, n, k. 1<=m<=75 1<=n<=75 n+m-1<=k<=2*(((m-1)/4)*((n-1)mod 4)+((n-1)/4)*(m-1))+m+n-1 m, n.......dimensions of maze for the warden k......exact lenght of the shortest path from start to the end Output explanation: For each of wardens output m lines containing n characters, where each character is a wall (#) or free square (.). If there are more solutions, choose any ONE of them. If its impossible to create maze from given inputs, output for that warden on one line "Impossible". (this means that m are lines, n are columns) Examples: https://snag.gy/qfYL7o.jpg https://snag.gy/2FDkf3.jpg I have written only requests for dimensions of each warden, now I think Im done ;( My code: #include <iostream> #include <math.h> using namespace std; int main() { int t, m, n, k, nk, vk; cout << "Zadejte pocet dozorcu (od 1 do 1000)" << endl; // INPUT NUMBER OF WARDENS cin >> t; for (int i=1;i<=t;i++) { nk=0; vk=0; cout << "Rozmery oblasti " << i << ". dozorce:" << endl; // DIMENSONS OF MAZE OF i WARDEN cout << "Zadejte m (od 1 do 75)(pocet radku)" << endl; // INPUT M cin >> m; cout << "Zadejte n (od 1 do 75)(pocet sloupcu)" << endl; // INPUT N cin

9th Dec 2018, 8:22 PM
Lukas Schobel
Lukas Schobel - avatar
1 Antwort
0
Hi Lukas Schobel, but you should post this on your personal feed. https://www.sololearn.com/discuss/1316935/?ref=app
9th Dec 2018, 9:29 PM
ShortCode