Code works excep for menu please help

My Whole Code works but Im having trouble with my int main Options menu can some please check that for me and tell me what I'm doing wrong??


#include <iostream>
#include <math.h>

using namespace std;
static const float PI = (float)(2*acos(0.0));

float period(float length,float g)
{
return (float)(2*PI*sqrt(length/g));
}

int a=0;
int b =0;
int c =0;

typedef struct node
{
int* val1;
int* val2;
struct node* left;
struct node* right;
int isleaf;
int* ptrs[3];
}node;

//tree consturtcion
node node1 = {NULL,NULL,NULL,NULL,1, {&a,&b,&c } };
node node2 = {NULL,NULL,NULL,NULL,1, {&a,&c,&b } };
node node3 = {NULL,NULL,NULL,NULL,1, {&c,&a,&b } };
node node4 = {NULL,NULL,NULL,NULL,1, {&b,&c,&a } };
node node5 = {NULL,NULL,NULL,NULL,1, {&c,&b,&a } };
node node6 = {&a,&c,&node2,&node3,0, NULL };
node node7 = {NULL,NULL,NULL,NULL,1, {&b,&a,&c } };
node node8 = {&b,&c,&node4,&node5,0, NULL };
node node9 = {&b,&c,&node1,&node6,0, NULL };
node node10 = {&a,&c,&node7,&node8,0, NULL };
node node11 = {&a,&b,&node9,&node10,0, NULL };

void rsort( node* ptr )
{
if(ptr->isleaf ==1){
int i=0;
int value;
cout<<"printing the sorting order\n";
while(i < 3)
{
value = *(ptr->ptrs[i]);
cout<<value;
i++;
}
return;
}
if ( *(ptr->val1) < *(ptr->val2) ){

return rsort(ptr->left);
}
else{

return rsort(ptr->right);
}
}


int sort3(int vala,int valb, int valc)
{

a = vala;
b = valb;
c = valc;

rsort(&node11);
}




int main()
{
sort3(5,5,1);

return 0;


}
template <class T>
bool is_valid(const T& tMin, const T& tMax, const T& number)
{
return number <= tMax && number >= tMin ? true : false;
}

template <class T>
T get_number(const string& strPrompt, const T& tMin, const T& tMax)
{
bool bContinue = false;
cout << strPrompt;
T tRet;
do {
cin >> tRet;
bContinue = !is_valid(tMin, tMax, tRet);
if (bContinue) {
cout << "Range: " << tMin << " <= x <= " << tMax << endl;
}
} while(bContinue);
return tRet;
}

double get_base(double& a, double& b)
{
a = get_number("a: ", 1.0, 30.0);
b = get_number("b: ", 1.0, 30.0);
return sqrt(a * a + b * b);
}
int quadratic(int a, int b, int c, double &r1, double &r2)
{
if(pow(b,2)-4*a*c < 0)
{
cout << "Non real result"<<endl;
return -1;
}
else
{
r1= (-b + sqrt( pow(b,2) - 4*a*c)) /(2*a);

r2= (-b - sqrt(pow(b,2) - 4*a*c)) /(2*a);
return 1;
}
}

unsigned long trib( unsigned int n )
{
return ( ( n < 3 ) ? 1 : trib( n - 1 ) + trib( n - 2 ) + trib( n - 3 ) );
}
int main()
{
char letter; //Below begins the outputs to execute the functions

cout << "This program allows you to execute five functions.\n\n Options Menu:";
cout << "Enter 'a' to compute period.\n Enter 'b' to compute sort 3.\n Enter 'c' to compute triplets.\n Enter 'd' to compute a Quadratic Equation.\n Enter "e" to compute unsigned long.\n";
cout << "Enter the letter from the options menu for your desired function: ";
cin >> letter;

letter = toupper (letter);

while (!cin.eof())
{
switch(letter)
{
case 'A': periodIO();
break;
case 'B': sort3IO();
break;
case 'C': tripletsIO();
break;
case 'D': quadraticEquationIO();
break;
case 'E': unsignedLongIO();
break;

}

cout << "";
cin >> letter;
letter = toupper (letter);
}

return 0;
}
Topic archived. No new replies allowed.