C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 14th, 2004, 08:30 PM
vamshi_av1 vamshi_av1 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 2 vamshi_av1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
copying numbers into an array without repetition

hi , please help me out with this issue,
i have two arrays A and B. For example
A = { 3 , 3, 5,6 , 8, 9, 0, 8, 6}
B = { }
i have to copy numbers of array A into array B with out
repetition and the program should give the count of each
occurence of number(for eg 3's count is 2)
please help me out with this,
thanks in advance
vamshi

Reply With Quote
  #2  
Old December 2nd, 2004, 01:54 PM
Kedishen Kedishen is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 5 Kedishen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Dunno if this could be counted at iteration or not. Its called recursion i think. When a function calls itself.

Code:
   #include <iostream.h>
   
   void copyarray (int*, int*, int);
   
   int main ( void )
   {
       int a[9] = {1,2,3,4,5,6,7,8,9};
       int b[9];
   
       copyarray ( a ,b, 0 );
   
       for (int i = 0; i < 9; i++ )
          cout << b[i] << ' ';
   
   return 0;
   }
   
   void copyarray (int *a, int *b, int i)
   {
       if (i <= 9)
       {
 	       b[i] = a[i];
 	copyarray ( a, b, i+1 );
       }
   }
 

Reply With Quote
  #3  
Old December 3rd, 2004, 09:38 PM
Evoltix Evoltix is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Nebraska
Posts: 14 Evoltix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Evoltix Send a message via Yahoo to Evoltix
Could you specify what parts of the program can't be iterated? Iteration will have to be used in some part of the program but there's an approach using OOP that can make it look like there's no iteration within the main() function. Get back to me on those specifications.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > copying numbers into an array without repetition


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway