Thursday, July 30, 2009

C++ program to generate the following series?

call u please give c++ program code to generate the following series:


Good


dGoo


odGo


oodG





the last character is shifted to the first position every time.

C++ program to generate the following series?
//This shud work


void main()


{


cout%26lt;%26lt;"Enter string: ";


char ch[50], c;


gets(ch);


int length;


length = strlen(ch);


for(int i=0;i%26lt;length;i++)


{


c = ch[length-i-1];


for(int j=length-1;j%26gt;=0;j--)


{


ch[j] = ch[j-1];


}


ch[0] = c;


puts(ch);


}


getch();


}
Reply:string str="Good";


int i = str.size();


do{


cout %26lt;%26lt; str %26lt;%26lt; endl;


str.push_back(*str.begin());


str.erase(str.begin());


}while(--i%26gt;0);


No comments:

Post a Comment