Hey, pls hlp cause im dumb. :)
Posted: September 26th, 2017, 10:01 pm
All you need to know is that this program is meant to ask if the coordinates x, y have to be visited.
then it is supposed to print out all of the coordinates that need to be visited. input r to skip to print.
Mainly what happens is when it prints it only prints coordinates where the y is 0.
it does some other weird stuff, when you don't finish it prints x (0-max) and y (Huge number)
Have fun
then it is supposed to print out all of the coordinates that need to be visited. input r to skip to print.
Mainly what happens is when it prints it only prints coordinates where the y is 0.
it does some other weird stuff, when you don't finish it prints x (0-max) and y (Huge number)
Have fun
Code: Select all
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int main()
{
bool city[5][6] = {0};
char buffer;
int Cities = 0;
unsigned int i = 0;
unsigned int r = 0;
char Comformation_Buffer;
cout << "Welcome to the traveling salesman algorithm. It is to figure out the most efficient path between all \n of the diffrent places that the salesman must visit \n" << endl;
for(r = 0; r <= 5; r++){ if(buffer == 'r'){continue;}
for(i = 0; i <= 6; i++)
{
cout << "do the coordinates " << r << ", " << i << " need to be visited by the salesman. (Y)es/(N)o \n";
cin >> buffer;
if(buffer == 'r'){break;} //escape route
if(buffer == 'y' || buffer == 'Y'){city[r][i] = true; Cities++;}
else{city[r][i] = false;}
if(city[r][i] == true){cout << "the coordinates " << r << ", " << i << " need to be visited by the salesman. \n";}
else{cout << "the coordinates " << r << ", " << i << " do not need to be visited by the salesman. \n";}
cout << "is this correct? (Y)es/(N)o "<< endl;
cin >> Comformation_Buffer;
if(Comformation_Buffer == 'n' || Comformation_Buffer == 'N'){
if(i == 0){--r; i=6;}else{i--;}}
}
}
int coor[Cities][1] = {0};
int_fast16_t z = 0;
cout << "The coordanates of each city are \n";
for(r = 0; r <= 5; r++){
for(i = 0; i <= 6; i++){
if(city[r][i]==true)
{coor[z][0]=r;
coor[z][1]=i;
z++;
cout << coor[z][0] << ", " << coor[z][1] << endl;}
}
} system("pause");
return 0;
}