Harut Posted April 10, 2002 Author Report Share Posted April 10, 2002 guys i need help with C++!!! my prof assigned an extra work that i really want to do. it involves Console Graphics.he doesn't help us in anyway, excapt that he told us in what book to look for this stuff. i've got the book. everything seems to be easy and fun, but the book refers to MSOFTCON.CPP file, which supposedly is on my computer. however it is not. so, now i'm just stuck. do you guys have any suggestions??? Quote Link to comment Share on other sites More sharing options...
Sip Posted April 10, 2002 Report Share Posted April 10, 2002 What do you mean by console graphics? I have never heard of such a thing. You mean graphics using "ASCII" art? C/C++ has no standard thing for graphics. You have to use special libraries (like OpenGL, etc) or do it in Windows. Either way, I could help I think so don't worry ... just give me some more details (what compiler are you using and what you have to do) Quote Link to comment Share on other sites More sharing options...
Sip Posted April 10, 2002 Report Share Posted April 10, 2002 Ok I found out what it is. It is pretty interesting ... it does graphics using text as I was suspecting !!! I found the files you want and a sample program at some site. I compiled it with Visual C and everything works great. I put a zip file with the source and my compiled exe at CLICK HERE. I compiled using >cl circles.cpp msoftcon.cpp(circles is the program and msoftcon is the "library". Circles includes the msoftcon.h file so you need that too) In case you need more info or the Visual C project files, go to THIS SITE. Happy coding!!! Quote Link to comment Share on other sites More sharing options...
Harut Posted April 10, 2002 Author Report Share Posted April 10, 2002 thank you Sip. this was exactly what i was looking for. the sample code you gave is acctually in my book. i just didn't have those msoftcon files. well, i think it's time for me to start using google. Quote Link to comment Share on other sites More sharing options...
Sip Posted April 10, 2002 Report Share Posted April 10, 2002 Sometimes it is pretty amazing what you can find on Google! Also, www.deja.com is a very good source. Now it redirects to http://groups.google.com and it basically searches all newsgroup archives. Can you believe I am almost done with university and I have been to the Library about 3 times? And even then, each time I go there to copy things on the copy machine I feel so shameful Quote Link to comment Share on other sites More sharing options...
Sip Posted April 10, 2002 Report Share Posted April 10, 2002 No I am talking about that place where most armenian/persian students at UCLA go to meet girls!!! On second thought ... maybe I should have gone to the library much much more to "study" and "read" Quote Link to comment Share on other sites More sharing options...
Azat Posted April 11, 2002 Report Share Posted April 11, 2002 Dohhhhhhhh! is that where they hang around? I am an idiot, I should have spent more time in the library. Quote Link to comment Share on other sites More sharing options...
Harut Posted April 11, 2002 Author Report Share Posted April 11, 2002 :)library? are you talking about that place where students take a nap in the smells of books? Quote Link to comment Share on other sites More sharing options...
Harut Posted May 15, 2002 Author Report Share Posted May 15, 2002 guys, i'm having a little problem with C++.here is a mini program i just wrote. i guess you can figure out what it does.the problem is at the duplicate part.when i enter numbers such as 1 2 3 4 5 6 7 8 9 1 it works fine. but when i enter numbers such as 1 2 3 4 5 6 7 8 1 1 it shows duplicate numbers three times, one for each pair of matching numbers ( first nineth, first tenth, nineth tenth ). any suggestions how i can accomplish what i want? code: // Lab 10// 1-D Array Search//// Harut// May 14, 2002//// This program is designed to accept 10 incomes from the user,// find the highest one, find the lowest one, find any duplicates,// and display them in reversed order #include #include #include #define MAX_NO 10 int main(){ int income[MAX_NO] = {0}, duplicates[MAX_NO] = {0}, num_dup = 0, max, min; double total = 0, average; cout << "WELCOME!" << endl; cout << "nPlease enter 10 incomes one by one" << endl; for ( int i = 0; i < MAX_NO; i++ ) { cin >> income[i]; total += income[i]; if ( i == 0 ) { min = income[i]; max = income[i]; } if ( income[i] > max ) max = income[i]; if ( income[i] < min ) min = income[i]; } for ( i = 0; i <= MAX_NO; i++ ) { for ( int j = ( i + 1 ); j <= MAX_NO; j++ ) { if ( income[i] == income[j] ) { duplicates[num_dup] = income[i]; num_dup++; } } } average = total / MAX_NO; cout << "ntt***Household Income***" << endl; for ( i = 0; i < MAX_NO; i++ ) cout << setw( 25 ) << income[i] << setw( 13 ) << income[MAX_NO - i - 1] << endl; cout << "nThe highest income --- " << max << endl; cout << "The lowest income ---- " << min << endl; cout << "The average income --- " << setiosflags( ios::fixed | ios::showpoint ) << average << endl; for ( i = 0; i <= ( num_dup - 1 ); i++ ) { if ( num_dup > 0 ) cout << "Duplicate income ----- " << duplicates[i] << endl; } cout << "nThank you for using the program!" << endl; getch(); return 0;} Quote Link to comment Share on other sites More sharing options...
Harut Posted May 15, 2002 Author Report Share Posted May 15, 2002 here we go. take a look at this. i revised that part. code: for ( i = 0; i < MAX_NO; i++ ) { for ( int j = ( i + 1 ); j < MAX_NO; j++ ) { if ( income[i] == income[j] ) { test = 0; for ( int k = 0; k < MAX_NO; k++ ) { if ( duplicates[k] == income[i] ) break; test++; } if ( test == 10 ) { duplicates[num_dup] = income[i]; num_dup++; } } } } Quote Link to comment Share on other sites More sharing options...
Harut Posted May 15, 2002 Author Report Share Posted May 15, 2002 and why did i get unregistered? Quote Link to comment Share on other sites More sharing options...
Sip Posted May 15, 2002 Report Share Posted May 15, 2002 Harut it looks like something gets screwed up with the forum because of the strange characters in your post (???) ... can you post the source file on the web somewhere and post a link to it? That would probably be the best way. Quote Link to comment Share on other sites More sharing options...
Harut Posted May 15, 2002 Author Report Share Posted May 15, 2002 Sip, i just noticed that its only half of it.i'll do what you said.you can just delete that post of mine. Quote Link to comment Share on other sites More sharing options...
Harut Posted May 15, 2002 Author Report Share Posted May 15, 2002 here it is, try this linkand then clik on the link there. you need msoftcon.cpp and msoftcon.h files for it to work. [ May 15, 2002, 06:16 PM: Message edited by: Harut ] Quote Link to comment Share on other sites More sharing options...
Sip Posted May 16, 2002 Report Share Posted May 16, 2002 quote:Originally posted by Harut:Sip, i just noticed that its only half of it.i'll do what you said.you can just delete that post of mine.Done Everything seems to work now! I'll try to take a look at that file as soon as possible but keep in mind I'll be leaving early in the morning for Utah (and won't have internet access for a couple of weeks) ... Quote Link to comment Share on other sites More sharing options...
Harut Posted May 16, 2002 Author Report Share Posted May 16, 2002 quote:Originally posted by Harut:here it is, try this linkand then clik on the link there. you need msoftcon.cpp and msoftcon.h files for it to work.this is a link to my longest C++ program so far. i would like to get comments and suggestions on it. just keep in mind that the language is very new to me. one more comment, it works best on Win2000. it works on Win98, but you have to watch out what you input, and graphics can be messy. Quote Link to comment Share on other sites More sharing options...
Harut Posted May 16, 2002 Author Report Share Posted May 16, 2002 quote:Originally posted by Sip: quote:Originally posted by Harut:Sip, i just noticed that its only half of it.i'll do what you said.you can just delete that post of mine.Done Everything seems to work now! I'll try to take a look at that file as soon as possible but keep in mind I'll be leaving early in the morning for Utah (and won't have internet access for a couple of weeks) ...thanks Sip, and bari janaparh. Quote Link to comment Share on other sites More sharing options...
Sip Posted May 16, 2002 Report Share Posted May 16, 2002 First of all: code:for ( i = 0; i <= MAX_NO; i++ ) { for ( int j = ( i + 1 ); j <= MAX_NO; j++ )Watch out! The limit should be < MAX_NO not <=. Don't you just love C bugs? Next question is, what does it mean to "find duplicates?" does it mean to print the duplicate income just once? (I am assuming that is what it means). In that case, every time you see a duplicate (where you have income==income[j]) you have to go and check in your existing duplicates array to see if that income has already been seen. If NOT, then you add it to that array. But if it is already in the duplicates array, then you don't add it. This means another loop in that IF. Quote Link to comment Share on other sites More sharing options...
Harut Posted May 20, 2002 Author Report Share Posted May 20, 2002 i one more technical question about C++. what do you think, which of the following methods is better in variable naming? variableNameorvariable_nameorvariable_Name thank you Quote Link to comment Share on other sites More sharing options...
Azat Posted May 21, 2002 Report Share Posted May 21, 2002 iAlwaysNameMyVariablesLikeThis Quote Link to comment Share on other sites More sharing options...
Azat Posted May 21, 2002 Report Share Posted May 21, 2002 more important is to always stay consistant Quote Link to comment Share on other sites More sharing options...
Harut Posted May 21, 2002 Author Report Share Posted May 21, 2002 yes, Azat, i'm using that one too. it was just interesting to see what you guys do. Quote Link to comment Share on other sites More sharing options...
Harut Posted May 21, 2002 Author Report Share Posted May 21, 2002 People i'm having a problem.see if you can help.everything seems to be coded well, but it gives a problem.i think you can see what's wrong yourself.here it is.www.geocities.com/harutpakh/main Quote Link to comment Share on other sites More sharing options...
Sip Posted June 1, 2002 Report Share Posted June 1, 2002 Harut, do you still need help with this stuff? Quote Link to comment Share on other sites More sharing options...
Harut Posted June 4, 2002 Author Report Share Posted June 4, 2002 quote:Originally posted by Sip:Harut, do you still need help with this stuff?yes please. i found an alternative for the one i was having a problem. but right now i have to use getline() again, and again i'm having a trouble. so please help. and the first one, the lottery, if you have time just look over. i wrote it long time ago (1-2m months) . so, now i know much more just didn't have the chance to upgrade it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.