since this is an ordered list and it is searching where to place the new item in the list so it is in order, do i need another while loop to check for the duplicates, i know you need to go through the whole list and compare each item by moving another pointer along, i'm just not sure where in the insertNode where to code it. it uses the linkedlist.h file which i'll sent as well. I appreciate your help, thanks one again.

[code]#ifndef H_orderedLinkedListType

define H_orderedLinkedListType

include <iostream>

include <cassert>

include "linkedList.h"

using namespace std;

template<class Type>
class orderedLinkedListType: public linkedListType<Type>
bool search(const Type& searchItem);
//Function to determine whether searchItem is in the list.
//Postcondition: Returns true if searchItem is found in
// the list; otherwise, it returns false

void insertNode(const Type& newItem);
//Function to insert newItem in the list.
//Postcondition: first points to the new list and newItem is
// inserted at the proper place in the list.

void deleteNode(const Type& deleteItem);
//Function to delete deleteItem from the list.
//Postcondition: If found, the node containing deleteItem
// is deleted from the list; first points
// to the first node of the new list.
// If deleteItem is not in the list, an
// appropriate message is printed.

template<class Type>
bool orderedLinkedListType<Type>::search(const Type& searchItem)
bool found;
nodeType<Type> *current; //pointer to traverse the list

found = false;    //initialize found to false
current = first;  //start the search at the first node

while(current != NULL && !found) ...

I was wondering if anyone can give me an idea on how i can modify this function to check for duplicates, if it contains a duplicate, since duplicates are not aloowed, output a message.
Any help would greatly be appreciated.

[code]template<class Type>
void orderedLinkedListType<Type>::insertNode(const Type& newItem)
nodeType<Type> current; //pointer to traverse the list
trailCurrent; //pointer just before current
nodeType<Type> *newNode; //pointer to create a node

bool  found;

newNode = new nodeType<Type>; //create the node
assert(newNode != NULL);

newNode->info = newItem;   //store newitem in the node
newNode->link = NULL;      //set the link field of the node 
                           //to NULL

if(first == NULL)  //Case 1 
   first = newNode;
   current = first;
   found = false;

   while(current != NULL && !found) //search the list
        if(current->info >= newItem)
            found = true;
            trailCurrent = current;
            current = current->link;

   if(current == first)     //Case 2
        newNode->link = first;
        first = newNode;
   else             //Case 3
        trailCurrent->link = newNode;
        newNode->link = current;
}//end else

}//end insertNode[/code]<< moderator edit: added [url=][co[u][/u]de][/co[u][/u]de][/url] tags >>

Can Any one reccomend a good book in c++ on Game programming?

[QUOTE=marinme]That works too :)[/QUOTE]
Maybe i wasn't to clear what i need the program to do is this: Assume that people are arranged in a circle and are numbered from 1 to n. if we count every 4th person, removing a person as we count them off then the first person removed is 4 the second person removed is 8 the third person removed is 5 since the fourth person is no longer in the circle and so on. I need to print the order in which the people are removed from a given circle n= number of people and m is the number used to count off. I need a circular list to do this, not sure how to incorporate it until there is no one to delete.

[QUOTE=cblue]Does anyone know how to create circular linked list whose links are numbered from 1 to n specified by the user?[/QUOTE]
[code]struct Node
int info;
Node next;
Node(const int& x, Node
: info(x),
{ }

Node CreateList(int n)
first = NULL;
Node temp = NULL;
last = NULL;
for(int i = 1;i <= n;i++)
first = new Node(i,first);
first -> next = first;
temp = new Node(i,temp);
first = temp;
last -> next = first;

return last;

}[/code]<< moderator edit: added [url=][co[u][/u]de][/co[u][/u]de][/url] tags >>

here is the code thus far for a circular linked list, if a user enters 4 i want 1 2 3 4 inserted into the cingular list, how do i do it, not quite clear on it, any help would greatly be appreciated.

Does anyone know how to create circular linked list whose links are numbered from 1 to n specified by the user?

ok what i'm trying to do is take any integer typed in by the user strip the digits, then sort it put it back into a vector and output it back out for example if you input 34 i want to output 43 after it was sorted and so on.

does any one have an idea how to correct my code so it works? What it is suppose to do is take an integer and strip the digits and throw it in a vector and then take the sorted numbers and throw it into another vector. it then sums up the numbers and it is suppose to be quivalent to the original int.

in other words if 100 was entered then stripped and sorted it would look like
100 then would be 001 when summed would never equall 100 no matter what and the same or single digits and anything that contained a 0's.

here is the code thus far:

include <iostream>

include <cmath>

using namespace std;

include "tvector.h"// equivalent to vector

int Sort_The_Digits(int n);
tvector <int> Quick(tvector<int> & sorted_list,int first,int last);
int Pivot(tvector<int> & sorted_list,int first,int last);
void Swap(int & a,int & b);
void Heading();
int main()
tvector<int> list;
int num;
int sum;
cout << "\t\tEnter A Non-Negative Number: ";//prompts user to enter a number
cin >> num;

if(num < 0)
    num *= -1;
sum = Sort_The_Digits(num);
cout<<"The number: "<< num<<" is equivalent to: "<< sum<<" when sorted."<<endl;

return 0; 


int Sort_The_Digits(int n)
int value = 0;
int index = 0;
int product = 1;
tvector<int> list;
while(n > 0)
list = Quick(list,0,list.size()-1);
product = pow(10,list.size()-1);
cout << product << endl;
while(product >= 1)
value += list[index]
product /= 10;
cout << value;
return value; ...

i was wondering how to strip off digits one by one and store them into an array so i can sort them. For example if the user entered 7216. take the 7 stor into cell one, take 2 store it cell 3 ettc and then sort it so it looks like this 1267 and then output it back as a whole number instead of segments in other words tak 1 2 6 7 and concatenate it so it looks like 1267 whic is one thosand two hundred sixty seven. i'm not sure if i need a loop or not.

i was tinking something like this:

   if(n < 10)
     store n in tan array
         n/10 store in array
         n % 10 store it in an array until done
     if any one can clear this up i'd greatly appreciate, i know how to sort it i already wrote the sort and tested it on ints and that works fine, just need a way of stripping each digit one by one and storing into an array.

thanks everyone for your help, igot this one figured out.
you can delete or dis reguard this thread.

This is what i'm trying to do but am not sure how to convert it if it is > 9 to a b c d e or f?

Here is the code thus far:

[code]#include <iostream>
using namespace std;

include "prompt.h"

// recursion: print English form of each digit
// in an integer: 123 -> "one two three"

void PrintDigit(int num)
// precondition: 0 <= num < 10
// postcondition: prints english equivalent, e.g., 1->one,...9->nine
if (0 == num) cout << "zero";
else if (1 == num) cout << "one";
else if (2 == num) cout << "two";
else if (3 == num) cout << "three";
else if (4 == num) cout << "four";
else if (5 == num) cout << "five";
else if (6 == num) cout << "six";
else if (7 == num) cout << "seven";
else if (8 == num) cout << "eight";
else if (9 == num) cout << "nine";
else cout << "?";

void Print(long int number)
// precondition: 0 <= number
// postcondition: prints English equivalent of number

if(0 <= number && number < 16)
    Print(number /16);
    cout << " ";
    PrintDigit(int(number % 16));


int main()
long number = PromptRange("enter an integer",0L,1000000L);
cout << endl;

return 0;


not sure how to test if digit > 9 to print the appropriate letter a = 10 b =11
...f = 15.

<< moderator edit: added [url=][co[u][/u]de][/co[u][/u]de][/url] tags >>

thanks guys, now for the challenge, how would i convert an int to hexadecimal, using recursion, in other words write a recursive function, i know how to do it for base 2, but how do you accomdate for the letters a-f if the digits are greater than 9?

Can anyone give me an idea how to convert an int or decimal number into hexadecimal? I know how to do it for binary by dividing by 2 and using the modulus % operator, but how do you take into account a b c d e f if the integer is greater than 9? any ideas would greatly be appreciated.

Can Anyone explain to me what defines a symmetrical matrix and what is i'm looking for that mkes a matrix symmetrical, any help on this subject would greatly be appreciated. it would help me understand, so i can write the boolean function to test if a matrix is symmetrical or not.

thanks everyone for your help, i no longer need help with this program, got it all figured out and it's working perfectly.

Here is the code so far now where i'm stuck is how to put the first number into a temp variable call my function and then store the count into a variable and compare the count with the next number called after calling the function.

For example the numbers entered are 8 and 10
after the first call to my function the result is:

8 4 2 1 count = 4

next call

9 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 count2 = 20

last call
10 5 16 8 4 2 1 count3 = 7

once i compared the counter i found the longest sewuence out put the longest sequence, i'm stuck as to where to count and then compare the reults here is what i have so far.

[QUOTE=jwenting]do you know how to use interpunction?
your ramblings are completely incomprehansible.[/QUOTE]

[QUOTE=jifiii]I got a question one of my friends asked me to make a program that you type in the number 1-27 on the command line, and get the corresponding letter for it. Like if you enter 1 as the arguement you would get an A as an output, and if you type in 2, and get a B for the output and so on.[/QUOTE]

It would help if you supplied your code to see where you are having problems.

i'm trying to write a program that takes two numbers from the user prints out the sequence between the 2 numbers and then outputs wthe longest sequence

for example if the user inputed 8 and 10

it should out put

8 4 2 1
9 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1
10 5 16 8 4 2 1

i got the code as follows that does it for 1 number

#include <iostream>
using namespace std;

int f(int n);

int main()
int first;
cout << "Enter First Integer: ";
cin >> first;

while(first != 1) //test ithat first is not qual to 1
cout <<  first << " ";

first = f(first);//call function

cout << first << endl;

return 0;

int f(int n)

if(n %2 == 0)//test to see if even
return n /=2;

return n = 3*n+1;//is odd



i need it to do it for two numbers and out but the sequence between those two numbers and then compare them and output that number 9 is the longest sequence it contained 20 numbers any help with this would greatly be appreeciated. forgive me i'm new to the forum and i'm not sure how to use
the code tags.

How do you count charcters in C++? for example if the user inputs 1234 the output would be 4 and -1234 the output would be 5. also if a user enters a numbers until a 0 is entered it outputs the nunmber of positive numbers entered and the number of negative numbers entered. i know how to terminate the lop i'm not sure how to count the number of positive numbers and then the number of negative numbers entered. Any help on this would greatly be appreciated, i might be looking to much in to it, it's always the case lol. Thanks a bunch.

Does anyone know how to get a loop to display the numbers across the screen in groups of 10 usin a while loop?

for example

1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20 etc.....

Thanks i've got it, it works fine, thanks for your help


Either your mathematical notation is wrong, or your code is. And the parens are mildly confusing, can you be more specific as to their purpose?[/QUOTE]

does anyone have any ideas if this is correct or not?

Here is the formula i'm suppose to use:

i'm suppose to to write a complete program with a function using two parameters to calculate:

x(!)^n, where x(!)^n = x!! ... ! use BigInts For the calculations
                                   n times

this wis what I have, i don't think it's right, if you can tell me what is wrong, and correct it, i'd greatly appreciate it.

#include <iostream>
#include <cmath>
#include "bigint.h" //uses a class that is specified in my header file
                        //along with bigint.cpp
using namespace std;

BigInt Factorial(int num);

int main()
    int num;
    int power;
    int current = 0;
    cout << "Enter A Number: ";
    cin >> num;
    cout << "Enter A Power: ";
    cin >> power;
    while(current <= num)
        cout << current << "! = " << Factorial(pow(current,power)) << endl;
        current += 1;
    return 0;

BigInt Factorial(int num)
    BigInt product = 1;
    int count = 0;

    while(count < num)
        count += 1;
        product *= count;
    return product;

i know how to find prime numbers of several numbers, does anyone know hoew to find a prime sumber of a single number inputed by the ser using the following function and printing out if the number is prime

int mai()//asks for input
      int num;
      cout << "enter number:";
      cin >> num;

       call IsPrime;
       cout if prime or not

bool IsPrime(int n)
// precondition: n >= 0
// postcondition: returns true if n is prime, else returns false
//                returns false if precondition is violated     
    if (n < 2)                           // 1 and 0 aren't prime
    {   return false;                    // treat negative #'s as not prime
    else if (2 == n)                     // 2 is only even prime number
    {   return true;
    else if (n % 2 == 0)                 // even, can't be prime
    {   return false;
    else                                  // number is odd
    {   int limit = int(sqrt(n) + 1);     // largest divisor to check
        int divisor = 3;                  // initialize to smallest divisor

        // invariant: n has no divisors in range [2..divisor)

        while (divisor <= limit)
        {   if (n % divisor == 0)         // n is divisible, not prime
            {   return false;
            divisor += 2;                 // check next odd number      
        return true;                      // number must be prime

any suggestions would greatly be appreciated