I need help please

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2006
Posts: 1
Reputation: aileenveliz87 is an unknown quantity at this point 
Solved Threads: 0
aileenveliz87 aileenveliz87 is offline Offline
Newbie Poster

I need help please

 
0
  #1
Nov 29th, 2006
I need help in writing a fuction call delete_repeats that has a partially filled array of chararcters as a formal parameter and that delets all repeted letters from the array. It should also have two formal parameters: an array parameter and a formal parameter of type int that gives the number of array position used and when the letters are deleted the remaining letters are moved forward to fill in the gap. So far this is what I have :
  1. const max=30;
  2. char used [max];
  3. cout<<"Type in a word";
  4. cin>>word;
  5. for (int i=0;i<size-1; i++)
  6. for (int j=i+1; j<size; j++)
  7. if (word[i]==word[j])
  8. delete_repeat( )
  9.  
  10. void delet_repeat(char w[ ],int size)
  11. {
  12. for (s=j;s<size-1;s++)
  13. {
  14. word[s]=word[s+1]
  15. }

im very lost in this
Last edited by ~s.o.s~; Nov 30th, 2006 at 12:27 pm. Reason: Added code tags learn to use them yourself.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,578
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1486
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: I need help please

 
0
  #2
Nov 29th, 2006
please edit your post to use code tags. If you don't know how to use them you can find the instructions in the link in my signature below.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 14
Reputation: nattylife is an unknown quantity at this point 
Solved Threads: 3
nattylife nattylife is offline Offline
Newbie Poster

Re: I need help please

 
0
  #3
Nov 30th, 2006
lets say you have
char sMyString[6];

0 1 2 3 4 5
[A] [R] [R] [A] [Y] [\0]

you call delete_repeats ( sMyString, 0 );

so basically you want to delete A at position 3, but you cant just move everything to the right of it to the left. that would be too easy... think of a way to copy or move the positions after your target letter to the left ...
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,958
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 307
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: I need help please

 
0
  #4
Nov 30th, 2006
you might want to have a look in this thread. It's a very similar problem to yours.

Regards Niek
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC