Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 86,399 C++ Programmers. There are 1,480 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a C++ Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

WHY?

 
Reply to this topicStart new topic

WHY?

Vimrod
post 8 May, 2008 - 07:13 AM
Post #1


New D.I.C Head

*
Joined: 27 Mar, 2008
Posts: 18



CODE



This post has been edited by Vimrod: 8 May, 2008 - 06:17 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


manhaeve5
post 8 May, 2008 - 12:33 PM
Post #2


D.I.C Regular

Group Icon
Joined: 28 Dec, 2006
Posts: 462

Because, it checks if the number in the first array is in the second array, it returns true. So even if your first is 12222 and your second 11211 it will say true. U should set the ones uve already found into an unusaual integer, say -33.

lemme do that for u

CODE

bool sameValues(int a[], int b[], int size)
{
    bool sameValues = true;
         for (int i = 0; (i < size) && (sameValues == true); i++)
             {
                  bool bValFound = false;
                  for (int j = 0; (j < size) && (bValFound == false); j++)
                  {
                  bValFound = (a[i] == b[j]);
                  b[j]=-33;
                  }
             sameValues = bValFound;
             }
             return sameValues;
}


I didnt realy get the logic u used, but atleast try to understand what i'm saying smile.gif

Good luck
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Vimrod
post 8 May, 2008 - 05:08 PM
Post #3


New D.I.C Head

*
Joined: 27 Mar, 2008
Posts: 18

QUOTE(manhaeve5 @ 8 May, 2008 - 12:33 PM) *

Because, it checks if the number in the first array is in the second array, it returns true. So even if your first is 12222 and your second 11211 it will say true. U should set the ones uve already found into an unusaual integer, say -33.

lemme do that for u

CODE

bool sameValues(int a[], int b[], int size)
{
    bool sameValues = true;
         for (int i = 0; (i < size) && (sameValues == true); i++)
             {
                  bool bValFound = false;
                  for (int j = 0; (j < size) && (bValFound == false); j++)
                  {
                  bValFound = (a[i] == b[j]);
                  b[j]=-33;
                  }
             sameValues = bValFound;
             }
             return sameValues;
}


I didnt realy get the logic u used, but atleast try to understand what i'm saying smile.gif

Good luck

Thanx for the help!..Yup that seems to work for 11112 and 21112 as it will then display that it is not the same values, but then when i put 12345 and 54321 it says its different but it should be the same. This is getting so confusing, would sorting arrays be bettter, but how would u write that? Any help would be greatly appreciated!
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

no2pencil
post 8 May, 2008 - 06:11 PM
Post #4


DIC K-mart

Group Icon
Joined: 10 May, 2007
Posts: 3,324

This is the great evil of creating duplicate topics.

I believe that I posted this last night.

Also, you should make your topic titles a LITTLE bit less vauge.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

manhaeve5
post 10 May, 2008 - 05:29 AM
Post #5


D.I.C Regular

Group Icon
Joined: 28 Dec, 2006
Posts: 462

Try this
CODE

bool sameValues(int a[], int b[], int size)
{
    bool sameValues = true;
         for (int i = 0; (i < size) && (sameValues == true); i++)
             {
                  bool bValFound = false;
                  for (int j = 0; (j < size) && (bValFound == false); j++)
                  {
                  bValFound = (a[i] == b[j]);
                  b[j]=-33;
                  break;
                  }
             sameValues = bValFound;
             }
             return sameValues;
}
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
Time is now: 5/17/08 06:19AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month