[algogeeks] Re: bits

2011-08-28 Thread shady
already discussed, search the forum On Aug 28, 10:53 am, guna sekaran vgun...@gmail.com wrote: print 1 to 10 without using if,loops,goto, function call.recursion,etc -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] Re: bits

2011-08-28 Thread Dheeraj Sharma
class A { public: A() { static int cou; cout++couendl; } }; make object A x[10]; On Sun, Aug 28, 2011 at 11:30 AM, shady sinv...@gmail.com wrote: already discussed, search the forum On Aug 28, 10:53 am, guna

Re: [algogeeks] Re: bits

2011-08-28 Thread guna sekaran
@Dheeraj Sharma Thanks On Sun, Aug 28, 2011 at 11:43 AM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: class A {   public: A() { static int cou; cout++couendl; } }; make object A x[10]; On Sun,

[algogeeks] Re: bits groups

2010-12-21 Thread bittu
Convert the given number in to binary and stored into every bit into array now compare the a[i]==0 if true then print that value that is nithing but zero else number doesn't has zero in its binary form. e.g code is given below int binary_zero(int n) { for(int i=0;iarraylength;i++) { a[i]=n%2;

[algogeeks] Re: bits groups

2010-12-21 Thread bittu
hey in last program i forget to take a variable that the position of one so that we can print zero groups shashank -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To

Re: [algogeeks] Re: bits groups

2010-12-21 Thread shubham singh
u can see topcoder and codechef tutorials may help -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to

[algogeeks] Re: bits groups

2010-12-21 Thread rajessge...@yahoo.com
no need to store in array the function can look like this int fun(int n) { int i=0,count=0; boolean set=false; while(isizeof(n)*8) { if(n^1==1) { if(set==false) { count++; set=true; } } else set=false; n=n1; } On Dec 21, 6:07 pm, shubham singh shubhamsisodia0...@gmail.com wrote: u can see

Re: [algogeeks] Re: bits

2010-06-15 Thread Anurag Sharma
@jalaj endian specific. Anurag Sharma On Sun, Jun 13, 2010 at 11:54 PM, Modeling Expert cs.modelingexp...@gmail.com wrote: @jalaj Yes , this is endian ness specific. On windows/x86 linux which are little endian, ch[0] would be lower 8 bits. On solaris/power pc which are big endian this

[algogeeks] Re: bits

2010-06-13 Thread souravsain
@divya Lets keep discussions in t his group limited to Algos and problems neutral to any language. Request you to post these C++ / C language specific questions to those language specific groups. This will not only help this group remain confined to its core purpose but will help you get better

Re: [algogeeks] Re: bits

2010-06-13 Thread Rohit Saraf
@Souravsain : Is there any serious problem in this. Anyone can just add a [C++] in the subject and uninterested people can make filters in gmail :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay

Re: [algogeeks] Re: bits

2010-06-13 Thread divya jain
thanks to all :) @ souravsain sorry for the inconvenience On 13 June 2010 20:01, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @Souravsain : Is there any serious problem in this. Anyone can just add a [C++] in the subject and uninterested people can make filters in gmail :)

[algogeeks] Re: bits

2010-06-13 Thread souravsain
and @rohit you will get better insight into the topic by more expert people by posting the question in right forum. I guess thats a win-win situation for one who has the question as he is get to know more and for people you are interested in going through C++ questions as they will read views from

[algogeeks] Re: bits

2010-06-13 Thread souravsain
@rohit: This is not about any serious problem, its about asking ur self why then make different types of groups. You can also talk about art and music by adding [art] or [music] in subject or talk about any topic on earth. The question u need to ask is then why have different groups. This will

Re: [algogeeks] Re: bits

2010-06-13 Thread Rohit Saraf
I agree mass bombarding with such questions is not very good.. but one doesn't join groups and all for getting a few doubts cleared. Anyways, i have no problem with anything. :D -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and

Re: [algogeeks] Re: bits

2010-06-13 Thread jalaj jaiswal
hey i too have a doubt... and its just 1 ... i'll not ask c/c++ again,,, we have a union a{ int i; char ch[4]; } int here is of 4 bytes. i initialise i=512... what value will ch[0] get the upper 8 bits or the lower 8 bits... is it big

Re: [algogeeks] Re: bits

2010-06-13 Thread Pramod Negi
From last few days I'm seeing the question that is coming here is not algorithm specific. Purpose of this group is achieved or defeated??? Thanks Pramod Negi On Sun, Jun 13, 2010 at 9:48 PM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote: hey i too have a doubt... and its just 1 ... i'll not

[algogeeks] Re: bits

2010-06-13 Thread Modeling Expert
@jalaj Yes , this is endian ness specific. On windows/x86 linux which are little endian, ch[0] would be lower 8 bits. On solaris/power pc which are big endian this would be upper 8 bits. e.g. union a temp; temp.i = 0x12345678 //! here big end is 0x12 and little end is 0x78 then temp.ch[0] = 78

[algogeeks] Re: bits required to convert A to B

2009-08-17 Thread Miroslav Balaz
__bitcount(a ^ b), or use bitset32 or int x=0; int y=a^b; while(y) {x++;y=y-1;} return x; 2009/8/17 Pramod Negi negi.1...@gmail.com i guess XORing A and B and count the no of set bits will do. On Sun, Aug 16, 2009 at 11:09 PM, richa gupta richa.cs...@gmail.comwrote: Given two integers A

[algogeeks] Re: bits required to convert A to B

2009-08-17 Thread Oleg Šelajev
Somehow like that should work. int a, b; int c = a ^ b; // ^ - XOR, now c has selected bits only at positions of swapping int i =0; while(c){ //count bits of c c = c (c-1); i++; } return i; Oleg Šelajev (+372 5518336) 2009/8/16 richa gupta richa.cs...@gmail.com Given two integers A B.

[algogeeks] Re: bits required to convert A to B

2009-08-17 Thread umesh kewat
yup this will be also rite On Mon, Aug 17, 2009 at 11:21 AM, Pramod Negi negi.1...@gmail.com wrote: i guess XORing A and B and count the no of set bits will do. On Sun, Aug 16, 2009 at 11:09 PM, richa gupta richa.cs...@gmail.comwrote: Given two integers A B. Determine how many bits

[algogeeks] Re: bits required to convert A to B

2009-08-17 Thread umesh kewat
#includestdio.h int BitSwapReqd(int A, int B); { int tmp=1, count=0; while(A || B) { if(A1==B1) count++ A=A1; B=B1; } return count; } int main() { int a,b; printf(Enter the Value of A B\n); scanf(%d%d,a,b); printf(these no of bits required to convert from A to B = %d\n,BitSwapReqd(a,b)); return

[algogeeks] Re: bits required to convert A to B

2009-08-17 Thread umesh kewat
Sorry for 1st solution thr i dod one mistake now this one is rite one... #includestdio.h int BitSwapReqd(int A, int B); { int tmp=1, count=0; while(A || B) { if(A1 != B1) count++ A=A1; B=B1; } return count; } int main() { int a,b; printf(Enter the Value of A B\n); scanf(%d%d,a,b);

[algogeeks] Re: bits required to convert A to B

2009-08-17 Thread ankur aggarwal
xor and count the number of bit set ... On Mon, Aug 17, 2009 at 11:21 AM, Pramod Negi negi.1...@gmail.com wrote: i guess XORing A and B and count the no of set bits will do. On Sun, Aug 16, 2009 at 11:09 PM, richa gupta richa.cs...@gmail.comwrote: Given two integers A B. Determine how

[algogeeks] Re: bits required to convert A to B

2009-08-17 Thread umesh
#includestdio.h int BitSwapReqd(int A, int B); { int tmp=1, count=0; while(A || B) { if(A1 != B1) count++ A=A1; B=B1; } return count; } int main() { int a,b; printf(Enter the Value of A B\n); scanf(%d%d,a,b); printf(these no of bits required to convert from A to B = %d \n,BitSwapReqd(a,b));

[algogeeks] Re: bits required to convert A to B

2009-08-16 Thread Pramod Negi
i guess XORing A and B and count the no of set bits will do. On Sun, Aug 16, 2009 at 11:09 PM, richa gupta richa.cs...@gmail.com wrote: Given two integers A B. Determine how many bits required to convert A to B.how to write a function int BitSwapReqd(int A, int B); -- Richa Gupta