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 assignment.MUSKAN GURJAR #112

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
22 changes: 22 additions & 0 deletions muskangurjar 11 may/ques 1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

#include <iostream>
using namespace std;

int findSingle(int ar[], int ar_size)
{

int res = ar[0];
for (int i = 1; i < ar_size; i++)
res = res ^ ar[i];

return res;
}


int main()
{
int ar[] = {2, 3, 5, 4, 5, 3, 4};
int n = sizeof(ar) / sizeof(ar[0]);
cout << findSingle(ar, n);
return 0;
}
23 changes: 23 additions & 0 deletions muskangurjar 11 may/ques 2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <bits/stdc++.h>
using namespace std;

int minXOR(int arr[], int n)
{
int min_xor ;

for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)

min_xor = min(min_xor, arr[i] ^ arr[j]);

return min_xor;
}

int main()
{
int arr[] = { 9, 5, 3 };
int n = sizeof(arr) / sizeof(arr[0]);
cout << minXOR(arr, n) << endl;
return 0;
}

20 changes: 20 additions & 0 deletions muskangurjar 11 may/ques 4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using namespace std;
#include<string.h>
#include<math.h>
#include<algorithm>
int main()
{
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int ans = (int)(sqrt(n));
while(ans*(ans+1)/2<=n){
ans++;
}
cout<<--ans<<endl;
}

return 0;
}
44 changes: 44 additions & 0 deletions muskangurjar 11 may/ques 5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <bits/stdc++.h>
using namespace std;

double Square(double n, double i, double j)
{
double mid = (i + j) / 2;
double mul = mid * mid;
if ((mul == n) || (abs(mul - n) < 0.00001))
return mid;
else if (mul < n)
return Square(n, mid, j);

else
return Square(n, i, mid);
}

void findSqrt(double n)
{
double i = 1;

bool found = false;
while (!found) {

if (i * i == n) {
cout << fixed << setprecision(0) << i;
found = true;
}
else if (i * i > n) {

double res = Square(n, i - 1, i);
cout << fixed << setprecision(5) << res;
found = true;
}
i++;
}
}
int main()
{
double n = 3;

findSqrt(n);

return 0;
}
53 changes: 53 additions & 0 deletions muskangurjar 11 may/ques 6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

#include <bits/stdc++.h>
using namespace std;

double Square(double n, double i, double j)
{
double mid = (i + j) / 2;
double mul = mid * mid;


if ((mul == n) || (abs(mul - n) < 0.00001))
return mid;


else if (mul < n)
return Square(n, mid, j);


else
return Square(n, i, mid);
}

void findSqrt(double n)
{
double i = 1;


bool found = false;
while (!found) {

if (i * i == n) {
cout << fixed << setprecision(0) << i;
found = true;
}
else if (i * i > n) {

double res = Square(n, i - 1, i);
cout << fixed << setprecision(5) << res;
found = true;
}
i++;
}
}


int main()
{
double n = 3;

findSqrt(n);

return 0;
}