Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

11-may(1-5) #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Vikas_rajpurohit/11-may/1.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Vikas_rajpurohit/11-may/2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Vikas_rajpurohit/11-may/3.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Vikas_rajpurohit/11-may/4.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Vikas_rajpurohit/11-may/5.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions Vikas_rajpurohit/11-may/question1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include<bits/stdc++.h>
using namespace std;
int main()
{

int i,p=0,n,x;
vector<int> ar;
cout<<"Enter number of elements : ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter element "<<i+1<<" : ";
cin>>x;
ar.push_back(x);
}
for(i=0;i<ar.size();i++)
{
p=p^ar[i];
}
cout<<p;
}
26 changes: 26 additions & 0 deletions Vikas_rajpurohit/11-may/question2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include<bits/stdc++.h>
using namespace std;
int main()
{
int arr[]={9,17};
vector<int>ar;
int n;
cout<<"Enter length of array : ";
cin>>n;
int x,i;
for(i=0;i<n;i++)
{
cout<<"Enter element : ";
cin>>x;
ar.push_back(x);
}
sort(ar.begin(),ar.end());
x = ar[0]^ar[1];
int m;
for(int i=2;i<ar.size();i++)
{
x = min(x,ar[i]^ar[i+1]);
}
cout<<"Minimum xor value = "<<x;

}
10 changes: 10 additions & 0 deletions Vikas_rajpurohit/11-may/question3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,ans;
cout<<"Enter number of blocks : ";
cin>>n;
ans=(-1+sqrt(1+8*n))/2;
cout<<"Result = "<<ans;
}
26 changes: 26 additions & 0 deletions Vikas_rajpurohit/11-may/question4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include<bits/stdc++.h>
#define mod 1000000000
using namespace std;
int path(int A) {
long long int C[A];
C[0]=C[1]=1;
for(int i=2;i<A;i++)
{
C[i]=0;
for(int j=0;j<i;j++)
{
int x=(C[j]%mod*C[i-j-1]%mod)%mod;
C[i]+=x;
C[i]=C[i]%mod;
}
}

return C[A-1];
}
int main()
{
int n;
cout<<"Enter size of grid : ";
cin>>n;
cout<<"Result = "<<path(n);
}
34 changes: 34 additions & 0 deletions Vikas_rajpurohit/11-may/question5.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include<bits/stdc++.h>
using namespace std;
double fun(int n)
{
double l=0,u=n,m,res;
int count=3;
while(count!=0)
{
m = (l+u)/2;
res = m*m;
if(res==n)
{
return m;
}
else if(res>n)
{
u = m;
}
else
{
l=m;
}
count--;
}
return m;
}
int main()
{
int n;
cout<<"Enter number : ";
cin>>n;
double ans = fun(n);
cout<<"Square root of "<<n<<" is "<<ans<<endl;
}