Advertisement

05.07.2008 at 08:37PM PDT, ID: 23384990 | Points: 500
[x]
Attachment Details
add number to store it and shift the rest in the array not working
I have function in my code need to add either 0 or 1 and shit to left I buld this function and when I call it I saw that it didnt add the number and it put 0z in all the row .. couldnt trease the problem

although when I prent out the argument of the function it was taken the correct number for example :
final_index=0 should go to window1 and it working fine
value = 1 should add 1 in last diget and shit to left
I filled up all the array with number 7 in the inisilazation so I should see as output
77777777777777777771
but it cames all zeros
the Des is the row number in the arrays .
some other rows it print 7s there but it didnt add the value as it supose to shift then add.
the initialization of the values in the array at the bigining is
Doarc01::Doarc01()
{
                                for( i=0;i<windowsize;i++)
               for(int j=0;j<windowsize;j++)
            {
               Doarc01::window1[i][j]=7;
               Doarc01::window2[i][j]=7;
             }
}

when I call the function I wrote:
double x;
x= shift(final_index,1,Des);
can you spot where is the problem  ... the code of this function as following

thanks in advance
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
double Doarc01::shift(int final_index,int value, int Des)
{
	int count=0;
     
	 if(final_index==0)
	 {
		 for(int i=0;i<windowsize-1;i++)
		 {
         		  window1[Des][i]=window1[Des][i+1];
		 }
		  for( i=0;i<windowsize-1;i++)
			if( window1[Des][i]==0)
				count++;	 
		  window1[Des][windowsize]=value;
           }
	
	 else if(final_index==1)
	 {
		 for(int i=0;i<windowsize-1;i++)
		  window2[Des][i]=window2[Des][i+1];
		  for( i=0;i<windowsize-1;i++)
			if( window2[Des][i]==0)
			 count++;
		 
		  window2[Des][windowsize]=value;
	 }
	 double BLOOK=count/windowsize;
	 return BLOOK; 
}
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: tetoo
Question Asked On: 05.07.2008
Participating Experts: 2
Points: 500
Views: 0
Translate:
Loading Advertisement...
05.07.2008 at 08:58PM PDT, ID: 21522234

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 09:17PM PDT, ID: 21522315

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 11:56PM PDT, ID: 21522783

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 05:58AM PDT, ID: 21524188

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 10:10AM PDT, ID: 21526560

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 10:51AM PDT, ID: 21526911

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 11:22AM PDT, ID: 21527140

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 11:26AM PDT, ID: 21527182

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 11:35AM PDT, ID: 21527262

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 12:06PM PDT, ID: 21527531

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 12:07PM PDT, ID: 21527541

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 12:30PM PDT, ID: 21527718

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 12:35PM PDT, ID: 21527755

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 06:08PM PDT, ID: 21529751

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 09:45PM PDT, ID: 21530441

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 10:09PM PDT, ID: 21530499

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.10.2008 at 09:43AM PDT, ID: 21539600

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.13.2008 at 10:54AM PDT, ID: 21557503

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.13.2008 at 11:01AM PDT, ID: 21557574

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.15.2008 at 08:30PM PDT, ID: 21579791

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.15.2008 at 10:34PM PDT, ID: 21580237

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.15.2008 at 10:40PM PDT, ID: 21580254

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
05.07.2008 at 08:58PM PDT, ID: 21522234
Well, first thing I notice is that if count and windowsize are both ints, you might have to typecase them both before doing the division, because since count is always less than windowsize, or the result will be zero because C++ truncates the fraction part before converting to double.  Try this instead:

double BLOOK = ((int)count)/((int)windowsize);

If that doesn't work, there might be an indexing issue.

Luke
 
05.07.2008 at 09:17PM PDT, ID: 21522315
its not working .. really cant understand why it does tht becase its even not adding the value to the array
 
05.07.2008 at 11:56PM PDT, ID: 21522783

Rank: Genius

I assume that this :

                  window1[Des][windowsize]=value;

has to be :

                  window1[Des][windowsize - 1]=value;

Same for the window2 line ...


And what LukeyJay noticed should also be fixed, but differently than what he proposed :

                 double BLOOK = count / ((double) windowsize);

otherwise BLOOK will always be either 0.0 or 1.0
 
05.08.2008 at 05:58AM PDT, ID: 21524188
Absolutely right, Infinity, I was pretty tire last night......double not int, of course!

Luke
 
05.08.2008 at 10:10AM PDT, ID: 21526560
value has been added but still some rows have zeros instead of 7s and when it count zeros it gave wrong number in that case.

what is the reason than some rows have those zeros instead of 7s.

this is the last update of code  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
double Doarc01::shift(int final_index,int value, int Des)
{
	int count=0;
     
	 if(final_index==0)
	 {
		 cout<<"DES "<<Des<<endl;
		 cout<<"Value "<<value<<endl;
		 cout<<"b4 the shift fun ";
		 for(int i=0;i<windowsize-1;i++)
		 {
                     cout<<window1[Des][i]<<" ** ";
		   window1[Des][i]=window1[Des][i+1];
		   cout<<window1[Des][i]<<" ** ";
		 }
		  for( i=0;i<windowsize-1;i++)
			if( window1[Des][i]==0)
				count++;
			cout<<endl;
		  cout<<"Num of ZEEEEEEEROOOOOOz= "<<count<<endl;		
			 
		  window1[Des][windowsize-1]=value;
          for( i=0;i<windowsize;i++)
		  {
			  cout<<window1[Des][i]<<" ## ";
		  }
		  
	 }
	
	 else if(final_index==1)
	 {
		 for(int i=0;i<windowsize-1;i++)
		  window2[Des][i]=window2[Des][i+1];
		  for( i=0;i<windowsize-1;i++)
			if( window2[Des][i]==0)
			 count++;
		 
		  window2[Des][windowsize-1]=value;
	 }
	 
	 double BLOOK = count / ((double) windowsize);
 
	 return BLOOK; 
}
Open in New Window
 
05.08.2008 at 10:51AM PDT, ID: 21526911

Rank: Genius

>> what is the reason than some rows have those zeros instead of 7s.

You didn't show how you call this method, and what you expect it to do, so I can't really answer that. I'll need a bit more information :)
 
05.08.2008 at 11:22AM PDT, ID: 21527140
this function need to add either 0 or 1 and shfit to left .. I should fill up this array with any number apart from 0 or 1 because Im going to count zeros (and to count ones I do this when I call the method ) I filled up all the array with number 7 to recognize when it cout 0.
the initialization of the values in the array at the bigining is
Doarc01::Doarc01()
{
                                for( i=0;i<windowsize;i++)
               for(int j=0;j<windowsize;j++)
            {
               Doarc01::window1[i][j]=7;
               Doarc01::window2[i][j]=7;
             }
}

when I call the function I wrote:
 double Ablook;
Ablook=  shift(final_index,0,Des);

this method should return the number of zeros divided by 20 which is windowsize which will be in Ablook
and I call this method agin when I need to calculate how meny ones there I typed
double x, Bblook;
x= shift(final_index,1,Des);
Bblook=1- x;

 
05.08.2008 at 11:26AM PDT, ID: 21527182
I called the function twice in different places in the code inside switch

case SUCCES:{
//should count ones/windowsize ;
}
case Fail:{
//should count zeros/windowsize
}
 
05.08.2008 at 11:35AM PDT, ID: 21527262
output should be like this
first time 7 twinty times
after adding 1 will be
7 (19 times ) and in the last digit will be 1
when next time add 0 to the same row in the same array should be
7 (18 times) then 1 then 0 in the last digt
and so one

but even I have just relized aproblem that when I want to calculate the ones I said
double x, Bblook;
x= shift(final_index,1,Des);
Bblook=1- x;
but in that case it will asume the rest of the array all ones and count the 7s as ones ..and I cant count the ones inside the shift() function becase it would return just one vale .. OMG getting coplicated now
 
05.08.2008 at 12:06PM PDT, ID: 21527531
just ignor my last Comment for now becase the array will be filled with one before the block happen in the network .. just please need to now why at the bigining some rows in the array filled up with zeros instead of 7s this is the major problem now
 
05.08.2008 at 12:07PM PDT, ID: 21527541

Rank: Genius

>> OMG getting coplicated now

You can say that again. I'm afraid I don't entirely understand what you're trying to do ...

What's the specification for the code you're writing ? What's the big picture ?

Can you maybe show the whole code, because those little snippets you showed don't make a lot of sense to me :)
 
05.08.2008 at 12:30PM PDT, ID: 21527718
ok I ll forget about the code and explain the genral idea
Im trying to calculate the blocking probablity in network.. so when the packet recived number 1 should be add to the window1 or window2 based in the candidatepath or number zero will be added in case of backet didnt reach source back. (cos it has to go Des then go back to Source).

so shall we say 1st time packet btween source 3 and Des 9 has been sent thorgh candpath1(final_index=0 if packet use the 1st path) and reach source again the (value =1) will be add to the window1 becase packet came thorgh the 1st path and has got final_index=0 it will use window1 to add value to.
ok now with every sucss and fail of packets values of zeros and ones will be added to the window1 or widow2

I need to caculate those zeros and ones to know the blocking propability for each path.

example :
11001100011111111111 ( who window1 or window2 should looks like )
number of zeros here is 5 in that case I need the function to return  this vale 5/20 to use in my code.


and number of ones =15 then  15/20 which is (1-5/20) I calculate in case SUCCES

case SUCCES:{
//should count ones/windowsize ;
double x, Bblook;
x= shift(final_index,1,Des);
Bblook=1- x;
}
case Fail:{
//should count zeros/windowsize

}

hope its clear now ;)
 
05.08.2008 at 12:35PM PDT, ID: 21527755

Rank: Genius

Can you show the code you used as well as the input you gave ?
 
05.08.2008 at 06:08PM PDT, ID: 21529751
sorry if my comment a bit late but the code is too much to attach and Im prety sure that every thing connected to this part is here and its about those vales in the arrays
if there is another way to send the code rather than put here let me know
thnx
 
05.08.2008 at 09:45PM PDT, ID: 21530441
thanx I found where is the mistake :)
 
05.08.2008 at 10:09PM PDT, ID: 21530499

Rank: Genius

>> and Im prety sure that every thing connected to this part is here and its about those vales in the arrays

You only posted small snippets that make no sense without the rest of the code (as I said earlier).


>> if there is another way to send the code rather than put here let me know

You can attach the code to your post (upload it).
 
05.10.2008 at 09:43AM PDT, ID: 21539600
tetoo,

You have requested that we PAQ this question, but you have not posted your solution. If you do, we finalize this question for you.

Thank you for using Experts Exchange,

ForestDenizen
Community Support Moderator
http://www.experts-exchange.com/Q_23388456.html
 
05.13.2008 at 10:54AM PDT, ID: 21557503
yah sorry forgot to type the solution here in the declearation
Doarc01::Doarc01()
{
                                for( i=0;i<windowsize;i++)  ====>  i<Des
               for(int j=0;j<windowsize;j++)
            {
               Doarc01::window1[i][j]=7;
               Doarc01::window2[i][j]=7;
             }
}
the for loop should be < Des in the first loop coz the virtical in the array was number of destination .



 
05.13.2008 at 11:01AM PDT, ID: 21557574

Rank: Genius

That's only a small part of what you needed to do to fix your problem ... See the modifications we posted in this thread for the others.

Please also note, that I repeatedly asked for more information which you never gave ... You could have fixed this a lot sooner if you would have posted a bit more code :) Maybe a tip for the future ?
 
05.15.2008 at 08:30PM PDT, ID: 21579791
A request has been made in Community Support to close this question:
http://www.experts-exchange.com/Q_23388456.html

If there are no objections, a moderator will finalize this question in approximately 4 days as follows:
PAQ with refund using {http:#a21557503}

Please leave any recommendations here.

ForestDenizen
Community Support Moderator
 
05.15.2008 at 10:34PM PDT, ID: 21580237

Rank: Genius

As I said in my previous post : that's not the only thing that needed to be fixed (http:#21522234 and http:#21522783 resp.).

LukeyJay and me pointed out the issues in the code that was posted. After that, we needed more code, for which I repeatedly asked, but never really got :)

The problem that tetoo pointed out was invisible to us due to the lack of code ...
 
05.15.2008 at 10:40PM PDT, ID: 21580254
Agreed.
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628