NathanOliver 429 Veteran Poster Featured Poster

what do you mean by loop dies not exist? if you put !inFile.fail() inside your while it doesn't work?

NathanOliver 429 Veteran Poster Featured Poster

could you post the error that you are getting. or at least open your blinds ;)

NathanOliver 429 Veteran Poster Featured Poster

on line 159 you have score += 100; and you haven't initialized it yet. then only time before line 159 that score is used is when it was declared as int score; .did you delete a score = 0; when you added the enemy part?

NathanOliver 429 Veteran Poster Featured Poster

alright I looked into it and i forgot to add a least case scenario since my algorithm for making the sets always found the largest set to make the permutations. Now I'm running my minimum value to 2 since i already have 1 covered in the largest first set. my machine is a little old running and only has a 500 MHz processor with 640 MB ram so my total time was 120 ms with L = 7 and M = 3. I also fixed another error in my code. I forgot to have a return if the set was evenly divisible by M.
my output was

[[0,1,2,3,4], [5], [6]]
[[0], [1,2,3,4,5], [6]]
[[0], [1], [2,3,4,5,6]]
[[0,1,2,3], [4,5], [6]]
[[0,1], [2,3,4,5], [6]]
[[0,1,2,3], [4], [5,6]]
[[0], [1,2,3,4], [5,6]]
[[0,1], [2], [3,4,5,6]]
[[0], [1,2], [3,4,5,6]]
[[0,1,2], [3,4,5], [6]]
[[0,1,2], [3], [4,5,6]]
[[0], [1,2,3], [4,5,6]]
[[0,1], [2,3], [4,5,6]]
[[0,1], [2,3,4], [5,6]]
[[0,1,2], [3,4], [5,6]]
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <sys/types.h>
#include <sys/timeb.h>


using namespace std;

vector< vector< vector<int> > > MakeSubsets(vector<int>, vector< vector<int> >, int);

vector< vector<int> > CalculatePossibleSets(int, int, int, int);

vector<int> CalculatePossibleSetSizes(int, int, int);

void Print(vector< vector< vector<int> > >);

int main()
{
	_timeb start, end;
	unsigned int milliseconds, setSize, numberOfSets, maxSubSetSize, minimumSubSetSize;
	cout << "This program will find all possible subsets of consecutive numbers";
	cout <<	"\nfor a given number of sets and a given range of numbers.";
	cout << "\nPlease enter how large you want the set to be: ";
	cin …
NathanOliver 429 Veteran Poster Featured Poster

could you please explain exactly what you mean.

NathanOliver 429 Veteran Poster Featured Poster

Unfortunalry no. the syntax should be

strcmp(name.c_str(), other.name.c_str())
NathanOliver 429 Veteran Poster Featured Poster

ah okay. thanks AD

NathanOliver 429 Veteran Poster Featured Poster

shouldnt his char array be defined as something like char script[2][50] or do i have it backwards?

NathanOliver 429 Veteran Poster Featured Poster

strcmp takes is defines as

strcmp(const char*, const char*)

and you are trying to do

strcmp(string, string)

so what you need to do is convert the string to a char* and then use that for the strcmp function. Fortunately help does exist. The string type has a member method called c_str() which will return a const char* of the string. the definition for this is

const char * c_str();

So you could use this to make strcmp work for you. If you are still having problems post what you have again and I'd be happy to help again.

NathanOliver 429 Veteran Poster Featured Poster

Well to start things off i have be going a little STL crazy lately. I'm having fun playing around with all the things you can do so I decided to give this an entire STL approach. There is probably a faster way but this was fun and some good practice. I hope you guys enjoy this one.

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <sys/types.h>
#include <sys/timeb.h>


using namespace std;

vector< vector< vector<int> > > MakeSubsets(vector<int>, vector< vector<int> >, int);

vector< vector<int> > CalculatePossibleSets(int, int, int, int);

vector<int> CalculatePossibleSetSizes(int, int, int);

void Print(vector< vector< vector<int> > >);

int main()
{
	_timeb start, end;
	unsigned int milliseconds, setSize, numberOfSets, maxSubSetSize, minimumSubSetSize;
	cout << "This program will find all possible subsets of consecutive numbers";
	cout <<	"\nfor a given number of sets and a given range of numbers.";
	cout << "\nPlease enter how large you want the set to be: ";
	cin >> setSize;
	cout << "Please enter the number of subsets: ";
	cin >> numberOfSets;
	cin.get();
	_ftime(&start);
	maxSubSetSize = setSize - numberOfSets + 1;
	if (setSize % numberOfSets == 0)
		minimumSubSetSize = setSize / numberOfSets;
	else
		minimumSubSetSize = (setSize / numberOfSets) + 1;
	vector<int> numberSet;
	for (int i = 0; i < setSize; i++)
		numberSet.push_back(i);
	vector< vector<int> > permutations;
	vector< vector< vector<int> > > allSubSets;
	permutations = CalculatePossibleSets(setSize, maxSubSetSize, numberOfSets, minimumSubSetSize);
	allSubSets = MakeSubsets(numberSet, permutations, numberOfSets);
	Print(allSubSets);
	_ftime(&end);
	milliseconds = (end.time * 1000 + end.millitm) - (start.time * 1000 + start.millitm);
	cout << "\nToltal time was " << …
NathanOliver 429 Veteran Poster Featured Poster

at caut_baia

assuming we have class Foo

vector<Foo> bar
bar.push_back(Foo(1));

this is perfectly legal to do.

NathanOliver 429 Veteran Poster Featured Poster

Sorry I forgot. This also applies to line 112. and one other thing on line you are using a iterator after you change the vector. A iterator to a vector is no longer usable after the vector has been changed. sorry but you are going to have another way to do this.

NathanOliver 429 Veteran Poster Featured Poster

alright i figured it out. it is from line 104. you have for(i = 0; i <= (int) v.size(); i++) when it should be for(i = 0; i //<// (int) v.size(); i++) since you are doing <= you will run to size when you actually want to stop after size - 1

NathanOliver 429 Veteran Poster Featured Poster

i think the error you are getting is on line 65. you are starting with the subscript 6 but i believe the vector has only 6 elements so the last subscript would be 5. why don't you just use push_back for each element instead of insert since you are adding them to the end of the vector.

NathanOliver 429 Veteran Poster Featured Poster

at nerdinator

do you know that you are getting multiple entries of the same disjointed set?

NathanOliver 429 Veteran Poster Featured Poster

could you please post the errors you are getting?

NathanOliver 429 Veteran Poster Featured Poster

Ah I See. Well Vernon thanks for that little tidbit.

NathanOliver 429 Veteran Poster Featured Poster

why is that? do you want to write matrix a = matrix b and then use another function or line of code to actual set the data in a to the data in b?

NathanOliver 429 Veteran Poster Featured Poster

>>Hi I M Rameshwar Prasad Sahu From Bilaspur, Chhattisgarh, I M working as computer faculty and Here the solution of your question Libraby Management System. If You have any problem with this coding Email me your problem at: <<EMAIL SNIPPED>>

My god how is this possible. I mean come on. If you are going to just give him the code you might as well just give him a job since you will be doing his work anyway. PLEASE refrain from just handing out answers.

jonsca commented: Yup +4
NathanOliver 429 Veteran Poster Featured Poster

where is the data vector in you matrix class definition. I'm seeing you using it in your constructors but its never defined. also in you operator= function you aren't copy the data from the other matrix. all you are doing is changing the size of the vector.

NathanOliver 429 Veteran Poster Featured Poster

no problem.

NathanOliver 429 Veteran Poster Featured Poster

I was going to wait and see what dusktreader wants but that is a very good idea Vernon. BTW is alright if I address you as Vernon?

NathanOliver 429 Veteran Poster Featured Poster

yes that does break what i said but than again he didn't say anything about prefixes or suffixes in his post. but that was a very good point out ;)

NathanOliver 429 Veteran Poster Featured Poster

for virtual functions http://www.codersource.net/c/c-tutorials/c-virtual-function.aspx

as for splitting the files the .h function should have the deceleration of the class and the .cpp should have the definitions of all the class function. something like this

//foo.h

class Foo
{
public:
       Foo();
       ~Foo() {}
private:
       int bar;
};

// foo.cpp
Foo::Foo()
{
       bar = 0;
}
NathanOliver 429 Veteran Poster Featured Poster

Another way to do this is have the whole name entered on one line than parse through the string and pull the names out of it. A good way would be to see how many space are in the string. if there are 2 spaces than you know you have a middle name or initial. If there is only one space than you only have a first and last name.

NathanOliver 429 Veteran Poster Featured Poster

I think I have made a solution to this. How would you like to see my code. I didn't know if I should post it or let others have a chance.

NathanOliver 429 Veteran Poster Featured Poster

code you post your class code. its hard to see your screen from here ;)

NathanOliver 429 Veteran Poster Featured Poster

is weight a private or public member?

NathanOliver 429 Veteran Poster Featured Poster

is plane a dynamically created array or just an array of objects?

NathanOliver 429 Veteran Poster Featured Poster

if you are talking about this line

pv = &i

then this is used to assign to the pointer pv the address of the variable i. thus making the void pointer an int basically

if you are talking about

void Foo(int & bar) {}

then you are passing the variable by reference so that whatever happens to the variable inside the function it will be that when you get back to the calling function.

NathanOliver 429 Veteran Poster Featured Poster

do you have to use a 2d char array? i would think it would be easier to use a string and vector and use the getline methode to extract from the file. something like

vector<string> dictionary;
string temp;
while (getline(inFile, temp))
       dictionary.push_back(temp);
NathanOliver 429 Veteran Poster Featured Poster

the problem is you are using random numbers so the situation changes every time. also you are not using srand before the first call to rand so you are using the same set of random numbers every time.

NathanOliver 429 Veteran Poster Featured Poster

could you please post your whole code where you set up your matrix?

NathanOliver 429 Veteran Poster Featured Poster

well big O notation is like a worst case scenario of what the function will do an upper bounds. take 1,2,3,4,5,6,7,8,9 as an example. if you passed this into your sort function it would run the minimum number of times. so depending of the values of the array the sorts will run differently

NathanOliver 429 Veteran Poster Featured Poster

well for starters your constructor on line 24 is not right. you are calling the set functions but not passing anything into them. you should just initialize the member variables right in the constructor instead of calling your set functions.

second you set numerator function will not allow 0 as a numerator. why is that? zero is a perfectly legal numerator to have.

third just as a matter of good coding practice you get functions should be const.

lastly for your operator == function you will either need to write a reduction routine in it or better yet write a reduce function that is a member of you class. after that you need to reduce both fractions to there simplest terms then compare the numerators and denominators to see if there equal.

NathanOliver 429 Veteran Poster Featured Poster

How big is the vector inside the vector? The main vector is of size 3 so the subscript [2] should be fine but I don't see anything for the size of each vector in distance. what would happen if you accesses distance[1][2]. Does that throw an exception?

NathanOliver 429 Veteran Poster Featured Poster

well it looks like you have a counter in each one. are they not counting correctly?

NathanOliver 429 Veteran Poster Featured Poster

Does this actually compile? In your encryption function you are overwritting the bounds of the encryptedChar string. I would suggest using the append function to add charactures to the string. Or make encryptedChar the same size as encrypt_code and then assign it with your index.

NathanOliver 429 Veteran Poster Featured Poster

i would use a while loop for your loop and have a counter variable. i would start the loop at the first posistion to delete than increment it by the value you entered first. i would check after incrementing to see if i exceded the size of the vector and if so then you would subtract the size from the counter and it would give you your next posistion to delete.

NathanOliver 429 Veteran Poster Featured Poster

i think the problem is that you are typing q to quit which sets the cin error state. try resetting the cin states to normal after your first while loop try a differnt way of ending the loop.


[EDIT]

^^^^^^^^^^^ bet me :(

NathanOliver 429 Veteran Poster Featured Poster

I belive you need to clear the input buffer before the second while loop

NathanOliver 429 Veteran Poster Featured Poster

No problem. Glad to help

NathanOliver 429 Veteran Poster Featured Poster

Delcare your function before main and try to compile agian

NathanOliver 429 Veteran Poster Featured Poster

you need to pass the string by reference into your function

string processWord(string & x)
{
	//Change all in string to uppercase
	  transform(x.begin(),x.end(),x.begin(),toupper);	
	  //Remove all non letter characters and numbers
	  x.erase(
      std::remove_if(x.begin(), x.end(), &isdigit), 
      x.end());




	   return x;


}
NathanOliver 429 Veteran Poster Featured Poster

i looked up remove_if and they called the function without a & in front of the function. not sure if that will help
http://www.cplusplus.com/reference/algorithm/remove_if/

NathanOliver 429 Veteran Poster Featured Poster

is it

#include <Transport.h>

// or

#include "Transport.h"
NathanOliver 429 Veteran Poster Featured Poster

we will assume the library is using 1 byte for each digit in the number you would need. then as 2 is multiplied by 2 each time it doubles and you get about 3 times before it adds another place to the number. so at best you would be looking at a piece of memory of (10^19991 / 3) GB. if there using different bases or what not it will go down but not by to much. I'm not sue if supercomputers can compute that or not but your desktop will never get there as the limits of memory are right now. may i ask why you need a 20,000 digit exponent?

NathanOliver 429 Veteran Poster Featured Poster

the simplest way i know to get every word by itself from input would be

vector<string> words;
string temp;
while(getline(cin, temp, ' ')
       words.push_back(temp);
NathanOliver 429 Veteran Poster Featured Poster

take that second piece of code you have and turn it into a function in the first piece of code you posted. like this:

#include <iostream.h>

#include <conio.h>

void WeeklySales();

main()
	{
   	int number;
      cout << "******Sales System******";
      do
      	{
            cout << ("\n\n");
      		cout << "1. Display Company Logo.\n"; endl;
      		cout << "2. Input/Validate weekly sales data.\n";endl;
      		cout << "3. Calculate weekly sales.\n";endl;
      		cout << "4. Display reciept.\n";endl;
      		cout << "5. SHUT DOWN & LOG OFF.\n";endl;
				cout << "\nEnter number...\n";endl;
         	cin >> number;
            cout << ("\n");

      		switch (number)
      			{
      				case 1:

            			cout << ("\n\tUU\tUU \tEEEEEEEE \tLL\t\t \SSSSSSS\n\tUU\tUU \tEE \t\tLL\t\tS\n\tUU\tUU \tEE \t\tLL\t\tS\n\tUU\tUU \tEEEEEEE \t\LL\t\t\ SSSSSS\n\tUU\tUU \tEE \t\tLL\t\t       S\n\tUU\tUU  \tEE  \t  \t\LL  \t\t       S \n\t UUUUUUUU   *\tEEEEEEEE  *\tLLLLLLL  *\tSSSSSSS   *\n\n\n\n\n");break;

            		case 2:

            			cout << ("Input/validate weekly sales data"); 
                                WeeklySales();  //<-------------   function call here
                                break;

            		case 3:

            			cout << ("Calculate weekly sales "); break;

            		case 4:

            			cout << ("Display receipt "); break;

            		case 5:

            			cout << ("Goodbye, and thank you for using U.E.L.S. ");break;

            		default:

            			cout << ("Enter a number from 1-5 only!");

         		}
      	} while (number !=5);
      getch();
   }

void WeeklySales()
{
//declare variables
	int salescode, bikeprice, modelcode, quantity, date;

   do
        //the instructions to enter the i.d. code will be repeated (do...while
        //loop) as long as the salescode is less than 1 or greater than 20.
   	{

      	cout << "\nPlease enter your identifiction code ";
         cin >> salescode;

         //the condition is tested
         if (salescode < 1 || salescode > 20)

         	{
            	cout << ("\nTHIS I.D. CODE IS NOT VALID. TRY AGAIN …
NathanOliver 429 Veteran Poster Featured Poster

Thanks for the input guys. Ill keep working on it.