Moore's Algorithm by Cheryl, Trey, and Omar

We made the following code to represent Moore's algorithm.

/
Math 2346
// Virgil Pierce
// 3/22/2010
// Program Homework #1

Omar
// Trey
// Cheryl


#include<iostream>
using namespace std;

int main()
{
cout « "*Welcome to our program!*" « endl;
cout « endl;

int total_verticies;
int counter = 0;
int ver_attached = 0;
char starting_letter;
char ending_letter;

cout « "How many total verticies are in your graph? ";
cin » total_verticies;
cout « endl;

cout « "What is the letter you are starting at? ";
cin » starting_letter;
cout « "What is the letter you are ending at? ";
cin » ending_letter;
cout « endl;

int s = total_verticies;

while(s != 1)
{
if(s == total_verticies)
{
cout « "How many verticies are connected to " « starting_letter « "? ";
cin » ver_attached;
s = s - ver_attached;
counter++;
if(s == 1)
{
break;
}
}
if(s != 0)
{
if(ver_attached + 1 == total_verticies)
{
cout « endl;
cout « "It should take a total distance of 1 to get from " « starting_letter « " to " « ending_letter « " .";
cout « endl;
cout « endl;

cout « "Thanks for using our shortest path calculator!" « endl;
cout « endl;

system("pause");
return 0;
}
cout « "How many verticies are connected to the previous " « ver_attached « " verticies? ";
cin » ver_attached;
}
s = s - ver_attached;
counter++;
if(s == 1)
{
break;
}
}

cout « endl;
cout « "It should take a total distance of " « counter « " to get from " « starting_letter « " to " « ending_letter « " .";
cout « endl;
cout « endl;

cout « "Thanks for using our shortest path calculator!" « endl;
cout « endl;

system("pause");

return 0;
}

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License