Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int bin(int );
- int bin(int n) //this fn retuns total no. of 1 in n * n
- {
- int i=0,j,n1,t,arr[100],count=0;
- t=n;
- while(n!=0)
- {
- n1=n%2;
- n=n/2;
- arr[i++]=n1;
- }
- for(j=i-1;j>=0;j--)
- {
- if(arr[j]==1)
- count=count+1;
- }
- return count*t;
- }
- int main()
- {
- int n,i,j,y,z;
- printf("Enter value of n:");
- scanf("%d",&n);
- for(i=0;i<=n;i++)
- {
- y=bin(i);
- for(j=i+1;j<=n;j++)
- {
- z=bin(j);
- if(y==z)
- {
- printf("Quarks pair: %d %d\n" ,i,j);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment