mam mera code run time error dikhaa raha hai aurmujhe jaaha tak lag raha hi woh extra spacing ki wajah se hai
can you please tell me about extra spacing… and optimize my code also.
#include
using namespace std;
int p;
int t;
int r;
int main()
{
int n;
cin>>n;
int a[n];
int b=0;
for(int i=0;i<n;i++)
{
cin>>a[i];
b=b^a[i];
}
int d=b;
int i=0;
while(d!=0)
{
int x=d&1;
d=d>>1;
{
if(x==1)
{
break;
}
}
i++;
t=i;
}
int m=0;
int c[1000];
int s=0;
for(int l=0;l<n;l++)
{
int mask=1<<t;
int g=a[l]&mask;
if(g>0)
{
c[m]=a[l];
s=s^c[m];
m++;
r=m;
}
}
p=s^b;
if(s<=p)
{
cout<<s<<" “<<p;
}
else
{
cout<<p<<” "<<s;
}
}
Unique number 2
hi @YASHMATHURIA123 C++ ignores whitespace so I am not sure what “extra spacing” are you talking about. I am sharing my code with you for your reference. https://ide.codingblocks.com/s/240353
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
1 Like