#include<iostream>
#include<list>
#include<string>
#include<vector>
void to_upper(std::string& str)
{
for(std::string::iterator it=str.begin(); it!=str.end(); ++it )
if( *it>='a' && *it<='z' )
*it-=32;
}
void to_lower(std::string& str)
{
for(std::string::iterator it=str.begin(); it!=str.end(); ++it )
if( *it>='A' && *it<='Z' )
*it+=32;
}
void to_ascending(std::string& str)
{
for(size_t i=1; i<str.size(); ++i)
{
char c=str[i];
int hole=i;
while(hole && c<str[hole-1])
{
str[hole]=str[hole-1];
--hole;
}
str[hole]=c;
}
}
void to_descending(std::string& str)
{
for(size_t i=1; i<str.size(); ++i)
{
char c=str[i];
int hole=i;
while( hole && c>str[hole-1] )
{
str[hole]=str[hole-1];
--hole;
}
str[hole]=c;
}
}
void to_reverse(std::string& str)
{
std::string rev;
for(std::string::reverse_iterator it=str.rbegin(); it!=str.rend(); ++it )
rev+=*it;
str=rev;
}
bool palindromes(std::string& str, std::list<std::string>& lst )
{
lst.clear();
std::vector<int> v;
std::string copy( str );
to_lower( copy );
size_t pos;
for(pos=0; pos<copy.size(); ++pos)
{
char& c=copy[pos];
if((c>='a' && c<='z') (c>='A' && c<='Z'))
{
if(v.size())
v.push_back(-1);
v.push_back(pos);
}
}
for(pos=1; pos<v.size()-1; ++pos)
{
size_t left=pos-1;
size_t right=pos+1;
while((left<right && right<v.size()) && (v[left]==-1 copy[v[left]]==copy[v[right]]))
{
--left;
++right;
}
do
{
++left;
--right;
}
while(v[left]==-1);
if(left<right)
lst.push_back(str.substr(v[left], v[right]-v[left]+1));
}
return(lst.size()!=0);
}
void process(const std::string& str)
{
std::cout<<"Original:\t""<<str.c_str()<<"""<<std::endl;
std::string mod;
mod=str;
to_upper(mod);
std::cout<<"to_upper:\t""<<mod.c_str()<<"""<<std::endl;
mod=str;
to_lower(mod);
std::cout<<"to_lower:\t""<<mod.c_str()<<"""<<std::endl;
mod=str;
to_reverse(mod);
std::cout<<"to_reverse:\t""<<mod.c_str()<<"""<<std::endl;
mod=str;
to_ascending(mod);
std::cout<<"to_ascending:\t""<<mod.c_str()<<"""<<std::endl;
mod=str;
to_descending(mod);
std::cout<<"to_descending:\t""<<mod.c_str()<<"""<<std::endl;
mod=str;
std::list<std::string> lst;
if(palindromes(mod,lst))
for each(std::string str in lst)
std::cout<<"Palindrome:\t""<<str.c_str()<<"""<<std::endl;
else
std::cout<<"No palindromes were found!\n";
std::cout<<std::endl;
}
int main()
{
std::string str;
str = "The quick brown fox jumps over the lazy dog.";
process(str);
str = "Madam, I'm Adam.";
process(str);
str = "In girum imus nocte et consumimur igni.";
process(str);
}
Output:
Original: "The quick brown fox jumps over the lazy dog."
to_upper: "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG."
to_lower: "the quick brown fox jumps over the lazy dog."
to_reverse: ".god yzal eht revo spmuj xof nworb kciuq ehT"
to_ascending: " .Tabcdeeefghhijklmnoooopqrrstuuvwxyz"
to_descending: "zyxwvuutsrrqpoooonmlkjihhgfeeedcbaT. "
No palindromes were found!
Original: "Madam, I'm Adam."
to_upper: "MADAM, I'M ADAM."
to_lower: "madam, i'm adam."
to_reverse: ".madA m'I ,madaM"
to_ascending: " ',.AIMaaaddmmm"
to_descending: "mmmddaaaMIA.,' "
Palindrome: "Madam"
Palindrome: "Madam, I'm Adam"
Palindrome: "m Adam"
Original: "In girum imus nocte et consumimur igni."
to_upper: "IN GIRUM IMUS NOCTE ET CONSUMIMUR IGNI."
to_lower: "in girum imus nocte et consumimur igni."
to_reverse: ".ingi rumimusnoc te etcon sumi murig nI"
to_ascending: " .Icceeggiiiiimmmmnnnnoorrssttuuuu"
to_descending: "uuuuttssrroonnnnmmmmiiiiiggeeccI. "
Palindrome: "um imu"
Palindrome: "In girum imus nocte et consumimur igni"
Palindrome: "umimu"
The INT function is to convert something into an integer. An integer is a number that goes out two decimal places.
jst subtract 32 from first character of string to convert it into capital
Prepare the string for processing: Remove all punctuation from the string (e.g., commas, hyphens, whitespace, etc). Convert to the same case (e.g., lower-case). Instantiate two pointers, one pointing at the first character, the other pointing at the last character. Process: If the two pointers are pointing at the same position or have crossed each other, the string is a palindrome. Otherwise, compare the characters being pointed at. If they are not equal, the string is not a palindrome. Otherwise, move both pointers one position towards the middle of the string and repeat the process.
/*To check whether a string is palindrome*/includeincludevoid main () {int i,j,f=0;char a[10];clrscr ();gets(a);for (i=0;a[i]!='\0';i++){}i--;for (j=0;a[j]!='\0';j++,i--){if (a[i]!=a[j])f=1;}if (f==0)printf("string is palindrome");else printf("string is not palindrome");getch ();}
You can't. HTML is a markup language. C is a programming language. You can make C generate HTML, but C isn't anything like HTML in the way it functions.
Listing the fractions is ascending (or descending) order.
Example 7, 30, 11, 27, 9, 16,Ascending Order = 7, 9, 11, 16, 27, 30 ( You simply arrange the number from lowest to highest number )Descending Order = 30, 27, 16, 11, 9, 7 ( You simply arrange the number from highest to lowest number )
Convert them to common denominators and put the numerators in ascending order.
Find the lowest common denominator, convert them, and arrange them in ascending order.
Its components
To capture sunlight and convert it into electrical energy.
liver
investors can convert their shares by selling them to stock exchange
The date functions that exist in SQL are "NOW()", "CURDATE()", "CURTIME()", "DATE()", "EXTRACT()", "DATEDIFF()", "GETDATE()", "DATEPART()", and "CONVERT()".
Chloroplast
It is to convert a function into a sum of sine (or cosine) functions so as to simplify its analysis.
You can the Text to Columns facility.