|
|
|||||||
| Computers & Information Technologies « Everything related to computers and internet. » |
![]() |
|
|
Share | Thread Tools | Search this Thread |
|
|
#1 |
|
Administrator
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
|
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. |
|
|
|
|
#2 |
|
info@sync.com.lb
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
|
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 |
|
|
|
|
#3 |
|
Super Moderator
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
|
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. |
|
|
|
|
#4 |
|
Administrator
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
|
thank u guys, i'll update u about his grades
__________________
signature |
|
|
|
|
#5 |
|
Registered Member
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
|
Hehehe
Thanks guys And thanks rami for posting the thread for me!!! |
|
|
|
|
#6 |
|
Registered Member
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
|
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 |
|
|
![]() |
|
| Tags |
| fellows, homework |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help! Homework ... | alex_scorpions | Computers & Information Technologies | 2 | 12-04-2006 07:15 PM |