C++ :: Recursive Palindrome Test With Merge Sorting
May 28, 2013
My assignment is to make a program that tests whether something is a Palindrome or not using a recursive function. Also, in order to test what type the Palindrome is (if it is indeed a palindrome) I'll need to merge sort it. Now alphabet characters, spaces, and numbers are all allowed, as long as the spaces line up with the spaces in the original input. And yes this is user inputted. I can show you what I've got so far and then I'll tell you what my problem is.
#include <iostream>
#include <istream>
#include <string>
#include <string.h>
#include <conio.h>
using namespace std;
/************To Test if Palindrome*******************/
bool IsPalindrome(char *str, int size) {
if( str[0] == str[size-1]);
[Code] .....
Now my problem is that I can't seem to get the test to work correctly. Since the word is user inputted I don't have any way of knowing the size so that kind of complicates it a little bit. The other thing is I was told by my professor that I need a boolean flag to make it work, and I need to set the value to the return of the IsPalindrome function. I'm not sure how to do that. I also don't haven't been able to add in the MergeSort yet, so the Order and Type don't really work correctly because I'm not sure how to get int len for it. (len is length)
I need to sort these students based on their test scores.
My biggest problem is with my sort function. I am not sure of the syntax to call the items the proper way. I also don't know how to call the function properly as I know that i can't pass a int to a struct. Also not sure about the z malloc. Just threw that one in there.
Code: struct student{ int id; int score; }; void sort(struct student* students, int n){ /*Sort the n students based on their score*/
So I am working on a dual pivot quicksort, I can correctly sort the array the first time around however in the main it is called again on the sorted array and in the function I get a seg fault at line 17 in sort.cpp, for the life of me I cant figure it out as the values are the same when I pass it in the first time. Here is the code:
main1.cpp
#include <iostream> #include "movement.h" #include "sort.h" using namespace std; int main() { const int size = 10; T array[size] = {6, 5, 1, 8, 4, 7, 2, 9, 6, 3};
i want to write an array sorting program that works with recursive function.but i can not do it.
my algorithm
Recursive find the min value find the min value and save it find the min value and save it and remove it from loop put the rest in loop again find the min value again .. ...
i didnt write the function because i dont know how will it work
Code:
#include<stdio.h> #include<stdlib.h> #define s 5 void main() { int a[s]={25,3,2,4,1},c[s]; // c[s] for new sorting int i,ek,j; //ek = min
Write a program that checks whether a string is a palindrome. A palindrome is a word, phrase, orsequence that can be read the same backward and forward.
Code: #include<iostream> #include<string> using namespace std; int main(){
p6.c.text+0x6a): undefined reference to 'palindromeness' collect2: 1d returned 1 exit status
This is program is suppose to check if a phrase is a palindrome or not.I need to write a function definition for _Bool palindromeness(char str[])but I am having a tough time figuring that part out. I am brand new to programming..this is my first class and I am just learning arrays and pointers.
I'm trying to write a function which can recognize whether a word is a palindrome. if it's the case , it must return 1 on screen, otherwise 0. This is the code which return 0 even in case of a palindrome...
Code: int IsPalindrom(char String[]){ int i,l; int counter=0; for(i=0;;i++){ //counts the number of array elements
So I've been tasked with creating a program that checks to see whether or not a string is a palindrome. It has to remove whitespace, punctuation, and capitalization for obvious reasons. Getting some errors which I'm not sure how to correct.
On an unrelated note, while programming in the console, my cursor has turned into a gray box and replaces characters when typing, instead of pushing them forward, etc. How do I return it to normal?
I am trying to create a simple palindrome program. I get the error string subscript out of range. I believe the error is either in the while or for loops.
#include <cctype> #include <string> #include <iostream> using namespace std; //cleans string, converts to lower bool cleanTolower(const string& s);
I am supposed to take the three string lines from a text file and then individually reverse them and state whether or not they are a palindrome. I have the three lines from the text file into string variables already but I am not sure on how to reverse them and then see if they are the same reversed(palindrome)
I had an assignment to do a palindrome program but im stuck in this part.
"This c-string will be sent to a function that will remove all spaces and punctuation marks from its c-string as well as change any uppercase letters to lowercase. Use string tokens to eliminate the spaces & punctuation marks. Make sure you include the NULL as you concatenate the tokens into a c-string. Then copy back into the original c-string for the pass by reference."