Vcoderz Community
We create websites that have it all, beauty & brains
Lebanon Web Design & Development - Coddict
 

Go Back   Vcoderz Community > Computer Zone > Computers & Information Technologies

Notices

Computers & Information Technologies « Everything related to computers and internet. »

Closed Thread
 
Share Thread Tools Search this Thread
Old 02-03-2007   #1
General
Administrator
 
General's Avatar
 
Last Online: 11-25-2011
Join Date: Sep 2004
Posts: 4,191
Thanks: 525
Thanked 2,025 Times in 1,461 Posts
Groans: 1
Groaned at 2 Times in 2 Posts
Default A homework for C++ fellows :D

Write a function which returns true if the string parameter is a palindrome. A palindrome is any "word" which is the same forward and backward, eg, "radar", "noon", "20011002", ... The function should return false if the argument is not a palindrome. Assume the prototype is
bool isPalindrome(char * s1);


Write a function which shortens a string s1 to n characters and stores the result in string s2. Assume the prototype is
void truncate(char *s1, char * s2, int n);



show us

(not for me, for a friend who needs the answers badly - special case)


__________________
signature

Last edited by General; 02-03-2007 at 10:57 PM.
General is offline  
Old 02-03-2007   #2
Sheriff Ice
info@sync.com.lb
 
Sheriff Ice's Avatar
 
Last Online: 11-29-2020
Join Date: Apr 2006
Posts: 3,827
Thanks: 1,348
Thanked 2,391 Times in 1,306 Posts
Groans: 0
Groaned at 16 Times in 15 Posts
Default Re: A homework for C++ fellows :D

man this is a program abt palindrom i dont know if its help u i tooke the course 2 years ago but i still have the programs so good luck.

--------------------------------------------------------------------
#include<iostream.h>

bool pal(char [],int,int);
int main()
{
const int size=11;
char a[size]="a bc ba";

cout<<pal(a,0,size-2)<<endl;
return 0;
}
bool pal(char a[],int low,int high)
{


if(a[low]==' ')
{
low++;
return pal(a,low,high);
}

if(a[high]==' ')
{
--high;
return pal(a,low,high);
}

if((low==high)||(low==high-1))
return true;

if(a[low]==a[high])
return pal(a,++low,--high);
else

return false;

}

-------------------------------------------------------------
__________________
http://www.gamync.com Lebanese Produced Mobiles Games by http://www.sync.com.lb
Sheriff Ice is offline  
Old 02-03-2007   #3
Kingroudy
Super Moderator
 
Kingroudy's Avatar
 
Last Online: 02-16-2022
Join Date: May 2006
Posts: 5,580
Thanks: 1,888
Thanked 2,653 Times in 1,593 Posts
Groans: 55
Groaned at 35 Times in 32 Posts
Default Re: A homework for C++ fellows :D

ex1:
bool ispalindrom (char *s1)
{
int length;
for (int i=0; s1[i]!='\0'; i++)
length=i+1;

for (int j=0; j<length/2; j++)
if (s1[j]!=s1[length-j-1])
return false;
return true;
}


ex2:
void truncate(char *s1, char *s2, int n=3)
{
for (int j=n; s1[j]!='\0'; j++)
s1[j]='\0';
for (int i=0;i<n; i++)
s2[i]=s1[i];
}
i'm very sure of those and not really sure about what crazysimo did, but believe me this is the way it is done
__________________
click on 'Groan' to switch to my left testicle.
Kingroudy is offline  
Old 02-03-2007   #4
General
Administrator
 
General's Avatar
 
Last Online: 11-25-2011
Join Date: Sep 2004
Posts: 4,191
Thanks: 525
Thanked 2,025 Times in 1,461 Posts
Groans: 1
Groaned at 2 Times in 2 Posts
Default Re: A homework for C++ fellows :D

thank u guys, i'll update u about his grades
__________________
signature
General is offline  
Old 02-03-2007   #5
Jules3
Registered Member
 
Jules3's Avatar
 
Last Online: 01-26-2008
Join Date: May 2006
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Groans: 0
Groaned at 0 Times in 0 Posts
Default Re: A homework for C++ fellows :D

Hehehe
Thanks guys
And thanks rami for posting the thread for me!!!
Jules3 is offline  
Old 02-03-2007   #6
god
Registered Member
 
god's Avatar
 
Last Online: 02-14-2010
Join Date: Mar 2006
Posts: 846
Thanks: 71
Thanked 293 Times in 217 Posts
Groans: 0
Groaned at 0 Times in 0 Posts
Default Re: A homework for C++ fellows :D

write your own |-( :-P yalla bassita.. thread locked.
__________________
--Capitalisation is the only difference between "I helped my uncle Jack off a horse" and "I helped my uncle jack off a horse" !!
http://img482.imageshack.us/img482/4889/hell7ta.jpg
god is offline  
Closed Thread

  Vcoderz Community > Computer Zone > Computers & Information Technologies

Tags
fellows, homework



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! Homework ... alex_scorpions Computers & Information Technologies 2 12-04-2006 07:15 PM


All times are GMT +1. The time now is 05:45 PM.


Lebanon web design and development
Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Share