Posts
 
Reputation
Loading chart. Please wait.
Joined
Last Seen
Ranked #4K
Strength to Increase Rep
+0
Strength to Decrease Rep
-0
100% Quality Score
Upvotes Received
6
Posts with Upvotes
6
Upvoting Members
5
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
1 Commented Post
~34.7K People Reached
Favorite Forums
Favorite Tags

66 Posted Topics

Member Avatar for ellisrn

You cant use [ICODE]int[/ICODE] for such big numbers as 100!, since [ICODE]int[/ICODE] usually can handle 32bit value. solution is google: "c++ big integer"

Member Avatar for Fbody
0
1K
Member Avatar for pecet

I've been trying to solve SQL exercises from [url]http://www.sql-ex.ru/[/url] for some time. You can find database description below: Short database description "Computer firm": The database scheme consists of four tables: Product(maker, model, type) PC(code, model, speed, ram, hd, cd, price) Laptop(code, model, speed, ram, hd, screen, price) Printer(code, model, color, …

Member Avatar for pecet
0
389
Member Avatar for LevyDee

[QUOTE=firstPerson;1243603]Maybe some code would help : [code] Shape allShapes[3] = { Shape(), Rectangle(), Circle() }; [/code][/QUOTE] AFAIK polimorphism works only for pointers and reference, so this should be array of pointers.

Member Avatar for AkashL
0
110
Member Avatar for codename.heaven
Member Avatar for vmirz

It's c-style string. You can read more here: [url]http://www.cprogramming.com/tutorial/lesson9.html[/url]

Member Avatar for chiwawa10
0
105
Member Avatar for pistol-pete

You have problems with semicolons. Lines 48-50: remove semicolon between function name and round brackets. You can also delete semicolon at the end of each of these lines. Line 51: missing semicolon after [ICODE]return totalCost[/ICODE] line 69: missing semicolon at the end of the line

Member Avatar for pecet
0
141
Member Avatar for gregarion

You need 3 things: - std::pair ([url]http://www.cplusplus.com/reference/std/utility/pair/[/url]) to keep both (name and the number) connected - std::sort ([url]http://www.cplusplus.com/reference/algorithm/sort/[/url]) - You need to create your own comparision function (You need to compare only second object from your pair object) - some kind of container, f.e. std::vector

Member Avatar for pecet
0
110
Member Avatar for gnarlyskim

I can see lot of pointers and [ICODE]new[/ICODE]/[ICODE]delete[/ICODE] stuff in your code. So the question is if You overloaded operator=. Cause maybe shallow copy causes troubles?

Member Avatar for gnarlyskim
0
130
Member Avatar for smokethecheeba

Use code tags. AFAIK the problem is in your finderase function. Let's assume that your vector looks like this: v[0]=5; v[1]=5; v[2]=6; v[3]=6; so the vector size is 4. Now, you want to delete value 6. Your finderase function looks like this: [CODE]void finderase(vector<int>&v,int &num) { for(int i=0;i < v.size();i++){ …

Member Avatar for pecet
0
116
Member Avatar for 2koolguy

What's more You missed [ICODE]"[/ICODE] at line 28. And read about using arrays, cause this: [CODE]person abc[3]; for (int i=0; i<3; i++) { abc.input(); } [/CODE] is completly wrong.

Member Avatar for 2koolguy
0
202
Member Avatar for turrence27

you have some problems with constructing [ICODE]for[/ICODE] loop. How many times this loop will be executed: [CODE]for(i=0; i < 0; i+=2)[/CODE] ? And here, the loop termination 'condition' is wrong: [CODE]for(i=0; vector_b.size(); i++)[/CODE]

Member Avatar for jonsca
0
2K
Member Avatar for PDB1982

add line [CODE]cout<<n<<endl;[/CODE] to your constructor and destructor and see results.

Member Avatar for pecet
0
137
Member Avatar for blackmagic01021

You mean something like this: [ICODE]int main(int argc, char *argv[])[/ICODE] ? If so, google: c++ int main parameters for more info.

Member Avatar for WaltP
0
104
Member Avatar for ahsanabbasdogar
Member Avatar for kux

Reference to vector is like just "another name" for your original vector. You still work on memory taken by your original vector. So if you worry, that internal vector could be copied - you don't have to. It won't be copied.

Member Avatar for kunal kislay
0
2K
Member Avatar for xxxSuperTrooper

1. Use code tags 2. Looks like you never increase [ICODE]firstNum[/ICODE], so [ICODE]while(firstNum != secondNum) [/ICODE] is always true.

Member Avatar for WaltP
0
745
Member Avatar for invisi

That's what I I have found at first look: lines#24-26: [CODE]for (int i = 0; i < 10; i++) { if(a[j] < a[i - 1])[/CODE] if [ICODE]i=0[/ICODE] and you have [ICODE]a[i-1][/ICODE], then You get [ICODE]a[-1][/ICODE]. That's the problem You have to solve.

Member Avatar for Narue
0
127
Member Avatar for aman rathi
Member Avatar for rena0514

Your numbers ARE being read. In fact if you look closer at your output You can see, that they all are read and something more is read (some trash). Why? You have only 34 values in your data file, but you try to read 124 values ([ICODE]SIZE_MONTH *SIZE_DAYS[/ICODE]) from the …

Member Avatar for vmanes
0
157
Member Avatar for green_leav

AFAIK you cant call [ICODE]delete[] temp[/ICODE] here (line #21). Am I right?

Member Avatar for green_leav
0
154
Member Avatar for NickRx
Member Avatar for gillanism

I'm really confused, now. Is this valid: [CODE]char word[]="\0"; cin>>word;[/CODE]

Member Avatar for gillanism
0
118
Member Avatar for Nexadus
Re: Lab

Maybe [ICODE]map/multimap[/ICODE] is the solution. [ICODE]N2O1[/ICODE] could be used as the key and [ICODE]NitrousOxide[/ICODE] as stored value. All elements in map are implicity sorted.

Member Avatar for Nexadus
0
113
Member Avatar for anthony5557

use [ICODE]getline()[/ICODE] and [ICODE]istringstream[/ICODE] and your problem should be solved.

Member Avatar for mrnutty
0
189
Member Avatar for group256

If You have 4 cities, you need 4x4 2d array (f.e. dist[4][4]) to store distance between each city. Another array(f.e. cities[4]) is needed to store city's number. Now, everything you need to do is to calculate all possible permutations of array cities (use std::random_shuffle in loop) and calculate total distance …

Member Avatar for pecet
0
1K
Member Avatar for pecet

I started to learn SQL recently. I downloaded some kind of assignment, where the goal is to design small database. I have two tables listed below: [CODE]create table SEA ( SEA_NAME varchar(50)constraint sea_prj_key primary key, AREA numeric(18, 0), );[/CODE] and: [CODE]create table NATION ( CTRY_NAME varchar(50)constraint sea_prj_key primary key, AREA …

Member Avatar for pecet
0
95
Member Avatar for ms_farenheit1
Member Avatar for DavidB
0
3K
Member Avatar for luliana
Member Avatar for amel036yippee

[CODE] for(r=0; r<board; r++) { //iterate through all elements from chosen row of board array //r is your row number in area array //value of current element from board array is an index of element in r-st row of area array and this element should be set to 1 } …

Member Avatar for amel036yippee
0
130
Member Avatar for bhey
Member Avatar for bhey
0
204
Member Avatar for pecet

Looks like I miss something, so I need your help, guys. [CODE] #include <iostream> using namespace std; int main() { int* ptr=new int(2); const int* constPtr=ptr; int** ptr2; //... do memory stuff for ptr2 const int** constPtr2=ptr2; typedef int** intPtr; const intPtr ptr3 = ptr2; return 0; } [/CODE] Questions: …

Member Avatar for pecet
0
165
Member Avatar for hamidvosugh

You can store all permutations in 2D vector. Then You need to create another vector with M! elements (indexes). Random_shuffle vector with indexes and you have order in which You should read data from 2D vector (with all permutations). But since (N < M) this algorithm is little overkill, because …

Member Avatar for hamidvosugh
0
209
Member Avatar for kavourdoukos
Member Avatar for pecet
0
91
Member Avatar for Jfunch

Use code tags. Probably your problem is in `void sequence::read()` method. You store some data to `local vector<int> v2`, then you try to read from `sequence::v2`, but this is completly another vector. And since it's not populated, you get seg fault. There are some other issues in code. You shuold …

Member Avatar for pecet
0
247
Member Avatar for BrownBearForU

what's interesting he already used random_shuffle at line #108: [CODE]random_shuffle(item.begin(), item.end());[/CODE]

Member Avatar for BrownBearForU
0
167
Member Avatar for gehring

@Clinton Portis: I suppose, at line #3, you wanted to write: [CODE]vector<vector<char*> > words; // this is vector of char* vectors[/CODE] if so, this won't work: [CODE]words.push_back(temp);[/CODE] Can be done like this: [CODE] vector<char*> v_temp; for(int i=0; i<wordcount; i++) { cout << "Enter a word (19 chars or less): "; …

Member Avatar for Clinton Portis
0
835
Member Avatar for nunchuckie

1. Create istringstream (f.e. [icode]istringstream my_stream[/icode]) from string stored in vector. 2. Create a while loop (until you reach eof of the stream) 3. Use operator >> and try to save to int variable (f.e. [icode]int my_int[/icode]). [icode]my_stream>>my_int;[/icode] 4. Check state of the stream. If it returns false, means that …

Member Avatar for Clinton Portis
0
115
Member Avatar for blamp

"nothing comes up on the output screen" - what does it mean? Doesn't menu show up on th screen? If it doesn't maybe problem lies here [CODE] void loadList(studentList & students) { ifstream infile; infile.open("registration.dat"); int student; while (!infile.eof() ) { infile >> student; students.push_back(student); } infile.close(); } [/CODE] When …

Member Avatar for pecet
0
132
Member Avatar for blahbla

Suppose you have two arrays: [CODE]tab1[]={1,1,1}; tab2[]={1,0,1};[/CODE] First iteration: [ICODE]tab1[0]==tab2[2] =>b=1;[/ICODE] second iteration: [ICODE]tab1[1]!=tab2[1] =>b=0; (so far, so good)[/ICODE] third iteration: [ICODE]tab1[2]==tab1[0] =>b=1 (again!)[/ICODE] The loop is over and you return b, your function says that arrays are equal which is not true. Solution: end the loop after second iteration …

Member Avatar for blahbla
0
220
Member Avatar for foxmulder

or just use random_shuffle if u can. [CODE] #include <ctime> #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { srand ( unsigned ( time (NULL) ) ); vector<int> numbers(50); vector<int> ordinary(10); vector<int> extra(5); for (int i=0;i<50;++i) numbers[i]=i+1; //roll for ordinary random_shuffle(numbers.begin(),numbers.end()); copy(numbers.begin(),numbers.begin()+10,ordinary.begin()); //roll for extra random_shuffle(numbers.begin(),numbers.end()); copy(numbers.begin(),numbers.begin()+5,extra.begin()); …

Member Avatar for foxmulder
1
102
Member Avatar for jacline

[CODE] int newsize= size++; Branch *temp=new Branch[newsize]; for(int i=0;i<size;i++){ temp[i]=branches[i]; } temp[size]=b; [/CODE] Let's say size is 10. So newsize is also 10. Then you increase size and now size=11. So your loop goes from 0 to 10. But temp[10] doesnt exist. Also temp[size] (which is temp[11] in this example) …

Member Avatar for jacline
0
12K
Member Avatar for T-Dogg3030

AFAIK this should work: [CODE] const int nulls=atoi(argv[2]); int arry[nulls]; [/CODE]

Member Avatar for Narue
0
199
Member Avatar for n3r3d

use [iCODE]std::getline()[/iCODE] with delimeter set to ';'. see: [url]http://www.cppreference.com/wiki/string/getline[/url] for more details

Member Avatar for pecet
0
259
Member Avatar for ms_farenheit1

Line 23. cout<<data[(i*rows)+j]<<" "; Why do You use variable rows here? Think about it:)

Member Avatar for Fajer91
0
110
Member Avatar for vinochick

create do-while loop in main function[CODE] do { //lines #19-#32 //ask user if he wants to quit ("press q to quit") //get his answer while (/*!(check if q was pressed)*/); [/CODE] What's more I suppose You'll have to reset some arrays/variables.

Member Avatar for pecet
0
2K
Member Avatar for Ponomous

You forget to initialize random seed: [CODE]srand ( time(NULL) );[/CODE] and this: [CODE]cards[r][c]=rand()%8+1;[/CODE] gives you just one random number.

Member Avatar for vb6exp32
0
239
Member Avatar for scott6480

What's more you should increment count variable at the end of the while loop, not at the beginning (before assignment).

Member Avatar for pecet
1
143
Member Avatar for Phil++

I don't see neither your class Manager definition, nor array 'm' def, but I guess something like that, should work: [CODE] Manager man1=(10, "name", "name", "sfsf", 15, 45, 10); m[1]=man1; [/CODE]

Member Avatar for Grn Xtrm
0
199
Member Avatar for hussamo

I have a question. Lines #21, #22 and #23: [CODE] employee *first=NULL; first=new employee; if(first==NULL){ //... [/CODE] If you allocate memory for pointer 'first', is that possible for 'first' to be NULL unless you get some exception?

Member Avatar for mrnutty
1
72
Member Avatar for infern0

change your do-while loop [CODE]do //.. while (score[x] != -1);[/CODE] to while loop: [CODE]while (cin >> score[x] && score[x]!=-1) { //... } [/CODE] Some other small changes will be necessary as well (x variable starts from zero and it should incremented at the end of the loop).

Member Avatar for pecet
0
118

The End.