|
Showing posts with label algorithms coding. Show all posts
Showing posts with label algorithms coding. Show all posts
Reverse each individual word in sentence?
void reversestr(char* str, char* strend)
{ char tmp; while(strend>str) { tmp = *strend; *strend = *str; *str = tmp; str++; strend--; } return; } void reverseSen(char *sentence) { char *wordstart=sentence, *wordstop=sentence; char *pSend=sentence,*pSstart =sentence ; int size=0; while(*pSend != '\0'){ pSend++; size++; } pSend--; // reverese stentence reversestr(pSstart,pSend); while(wordstop < pSend) { //find the word while((*wordstop!='\0')&&(*wordstop!=' ')) wordstop++; wordstop--; //reverese the word reversestr(wordstart,wordstop); wordstart = wordstop +2; wordstop = wordstart; } } Find out if a string is a palindrome?
bool Palindrome(char *str)
{ Find a repeated integer in array of size n?int DuplicatedNumber(int *a, int size) return founddup ? a[i] : -1; // return the duplicated value or -1 if not found WAP to reverse a linked list?void reverse(NODE **head) { } Recusive way call with original = list, parent = NULL Node* reverselinkedlist(Node* original, Node*parent) if(original == NULL) } return reverse; }
Subscribe to:
Posts (Atom)
|
Categories
Blog ArchiveRent A Coder |