Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 19-09-2008, 06:55 AM   #1 (permalink)
hsr
Senior Owner
 
hsr's Avatar
 
Join Date: Feb 2007
Posts: 730
Default need c++ source code


To reverse each word in a string without using functions.
eg: hari is bad
irah si dab

to find greatest on n numbers using arrays

thanks
__________________
Read Rules > FAQs > Stickies before posting a new thread. PM me anytime for an issue, and I'll be idle on irc too.
My dream rig.
ლ(ಠ_ಠ)ლ Webchat for Digit.
hsr is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 19-09-2008, 10:20 AM   #2 (permalink)
Human Spambot
 
Join Date: Jan 2007
Location: Lat 28.38°N , Longt 77.13°E
Posts: 2,431
Default Re: need c++ source code

Don't ask for whole code here. Just tell where you are finding trouble.
ThinkFree is offline  
Old 19-09-2008, 06:00 PM   #3 (permalink)
hsr
Senior Owner
 
hsr's Avatar
 
Join Date: Feb 2007
Posts: 730
Default Re: need c++ source code

well the reversing part of course ! cannot get it right.
__________________
Read Rules > FAQs > Stickies before posting a new thread. PM me anytime for an issue, and I'll be idle on irc too.
My dream rig.
ლ(ಠ_ಠ)ლ Webchat for Digit.
hsr is offline  
Old 19-09-2008, 06:02 PM   #4 (permalink)
-----ATi-----
 
nvidia's Avatar
 
Join Date: May 2007
Location: Bangalore
Posts: 2,322
Default Re: need c++ source code

Code:
for(i=0;i<l;i++)
reverse_string[i]=actual_string[l-i-1]
Where l = length of the string.
__________________
http://twitter.com/akshayms
nvidia is offline  
Old 19-09-2008, 06:11 PM   #5 (permalink)
hsr
Senior Owner
 
hsr's Avatar
 
Join Date: Feb 2007
Posts: 730
Default Re: need c++ source code

well it is for a whole string but i need per word maintaining the spaces :
eg: hari is bad
irah si dab
__________________
Read Rules > FAQs > Stickies before posting a new thread. PM me anytime for an issue, and I'll be idle on irc too.
My dream rig.
ლ(ಠ_ಠ)ლ Webchat for Digit.
hsr is offline  
Old 19-09-2008, 06:23 PM   #6 (permalink)
I see right through you.
 
Sykora's Avatar
 
Join Date: Sep 2005
Location: Chennai
Posts: 597
Default Re: need c++ source code

First post what code you have, and tell us where you're going wrong.
__________________
I didn't make the world, I only try to live in it.
http://lucentbeing.com
-- Sykora --
Sykora is offline  
Old 19-09-2008, 09:32 PM   #7 (permalink)
-----ATi-----
 
nvidia's Avatar
 
Join Date: May 2007
Location: Bangalore
Posts: 2,322
Default Re: need c++ source code

Greatest of N numbers:
Code:
//Input the numbers into an array
big=a[0];
for(i=1;i<n;i++)
{
 if(a[i]>big)
 big=a[i];
}
printf("%d",big);
__________________
http://twitter.com/akshayms
nvidia is offline  
Old 19-09-2008, 09:43 PM   #8 (permalink)
hsr
Senior Owner
 
hsr's Avatar
 
Join Date: Feb 2007
Posts: 730
Default Re: need c++ source code

not working, the program just terminates
__________________
Read Rules > FAQs > Stickies before posting a new thread. PM me anytime for an issue, and I'll be idle on irc too.
My dream rig.
ლ(ಠ_ಠ)ლ Webchat for Digit.
hsr is offline  
Old 19-09-2008, 09:44 PM   #9 (permalink)
-----ATi-----
 
nvidia's Avatar
 
Join Date: May 2007
Location: Bangalore
Posts: 2,322
Default Re: need c++ source code

^^Thats not the entire program! Did you add codes to input the array before that?
I just typed in the main part of the program..
__________________
http://twitter.com/akshayms
nvidia is offline  
Old 19-09-2008, 09:59 PM   #10 (permalink)
hsr
Senior Owner
 
hsr's Avatar
 
Join Date: Feb 2007
Posts: 730
Default Re: need c++ source code

yes and assignes big for string length
__________________
Read Rules > FAQs > Stickies before posting a new thread. PM me anytime for an issue, and I'll be idle on irc too.
My dream rig.
ლ(ಠ_ಠ)ლ Webchat for Digit.
hsr is offline  
Old 19-09-2008, 10:59 PM   #11 (permalink)
Legen-wait for it-dary!
 
dheeraj_kumar's Avatar
 
Join Date: Dec 2004
Location: Chennai
Posts: 2,471
Default Re: need c++ source code

Code:
int wordcount = 0, strcount = 0, revcount = 0, strposition = 0; // counters n stuff 
char string [100], word [10], rev [10]; // obvious

while (string[strcount] != '\0') // till end of string
{
 strposition = strcount; //save current position

 while (string[strcount] != ' ') // word has started
   word [wordcount++] = string [strcount++]; //move along the word, copying the entire word to buffer

 while (wordcount >= 0)
  rev [revcount++] = word [wordcount--]; //classic reversing the word loop

 while (revcount >= 0) // move back to where the word started(we saved the position remember?)
  string [strposition++] = rev [revcount--]; // copy the reversed word to the place, overwriting word
}
Untested, but should work. Done with arrays, change it a bit to pointers for more flexibility.
__________________
If the Start Windows Restart when Windows starts check box is checked Windows Restart will start automatically every time Windows is started. - Actual excerpt from a windows program help file
dheeraj_kumar is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft Goes Open Source?with part of silverlight source code expected to release praka123 Technology News 1 30-04-2007 11:00 AM
From exe to source code prashanthnbhat QnA (read only) 18 07-04-2007 10:50 PM
What do u exactly mean by source code? paragkalra Open Source 11 17-12-2006 05:05 PM
HELP:- NEED ASP.NET SOURCE CODE.!!! sanprince Software Q&A 1 23-03-2006 01:20 PM
About linux source code anup_sggs Open Source 2 13-04-2005 11:34 AM

 
Latest Threads
- by clinton
- by soumya
- by Sujeet
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 11:12 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2