Jump to content

Programming Languages


Harut

Recommended Posts

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???

Link to comment
Share on other sites

  • Replies 86
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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)

Link to comment
Share on other sites

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!!!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 month later...

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;

}


Link to comment
Share on other sites

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++;

}

}

}

}


Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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) ...
Link to comment
Share on other sites

quote:
Originally posted by Harut:

here it is, try this link

and 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.

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

i one more technical question about C++.

 

what do you think, which of the following methods is better in variable naming?

 

variableName

or

variable_name

or

variable_Name

 

thank you

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...