Re: [algogeeks] Re: MICROSOFT WRITTEN IN VASAVI

2011-09-15 Thread Dheeraj Sharma
char str[10]; int length,count; void fun(int x) { if(x==length) printf("%d %s\n",++count,str); else { fun(x+1); str[x]-=32; fun(x+1); str[x]+=32; } } int main() { scanf("%s",str); length=strlen(str); fun(0); getch(); }

Re: [algogeeks] Re: MICROSOFT WRITTEN IN VASAVI

2011-09-14 Thread mohit verma
take an array containing all original upper-case letters and their smaller case letters and now the problem is reduced to print all substrings containing length of original string. On Wed, Sep 14, 2011 at 8:55 PM, teja bala wrote: > > //dis one works check it out.. > > #include > #in

Re: [algogeeks] Re: MICROSOFT WRITTEN IN VASAVI

2011-09-14 Thread teja bala
//dis one works check it out.. #include #include #include #include void toggler(char* x, int pos) { if(pos==0){ printf("%s\n",x); return; } // printf("String is now: %s\n",x); x[pos-1] = toupper(x[pos-1]); toggler(x, pos-1); x[pos-1] = tolower(x[pos-1]); toggler(x, pos-1

[algogeeks] Re: MICROSOFT WRITTEN IN VASAVI

2011-09-14 Thread Dave
@Teja: Oops. I was wrong. By the time I fix my conceptual error, the code is no shorter than Anshu's. Dave On Sep 14, 8:14 am, teja bala wrote: > @DAVE > > dis was the o/p for ur prog. > > aBC > abC > abC > abc > abc > abc > abc > abc > > #include > main() > { > int i, n = 3; > char *s="ABC"; >

Re: [algogeeks] Re: MICROSOFT WRITTEN IN VASAVI

2011-09-14 Thread Shravan Kumar
1 wahat is the logic why 1< > > On Wed, Sep 14, 2011 at 6:44 PM, teja bala wrote: > >> @DAVE >> >> dis was the o/p for ur prog. >> >> aBC >> abC >> abC >> abc >> abc >> abc >> abc >> abc >> >> #include >> main() >> { >> int i, n = 3; >> char *s="ABC"; >> for( i = 0 ; i < (1<> { >> s[i^(i

Re: [algogeeks] Re: MICROSOFT WRITTEN IN VASAVI

2011-09-14 Thread UTKARSH SRIVASTAV
wahat is the logic why 1 @DAVE > > dis was the o/p for ur prog. > > aBC > abC > abC > abc > abc > abc > abc > abc > > #include > main() > { > int i, n = 3; > char *s="ABC"; > for( i = 0 ; i < (1< { > s[i^(i>>1)] ^= 'a' ^ 'A'; > cout << s << endl; > } > } > > > > -- > You received this

Re: [algogeeks] Re: MICROSOFT WRITTEN IN VASAVI

2011-09-14 Thread teja bala
@DAVE dis was the o/p for ur prog. aBC abC abC abc abc abc abc abc #include main() { int i, n = 3; char *s="ABC"; for( i = 0 ; i < (1<>1)] ^= 'a' ^ 'A'; cout << s << endl; } } -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to thi

[algogeeks] Re: MICROSOFT WRITTEN IN VASAVI

2011-09-14 Thread Dave
Shorter. It is assumed that the input string consists of upper and lower case letters only. void allCase(string r) { int i, n = s.sise(); for( i = 0 ; i < (1<>1)] ^= 'a' ^ 'A'; cout << s << endl; } } The expression i^(i>>1) is a Gray-code (see http://en.wikipedia.org/wiki/Gra