From 52dfb28cdc6eb98976a20157a4df8180fa7ca4a6 Mon Sep 17 00:00:00 2001 From: MuskanGurjar <55548799+MuskanGurjar@users.noreply.github.com> Date: Thu, 14 May 2020 00:38:29 +0530 Subject: [PATCH] 11 may assignment.MUSKAN GURJAR --- muskangurjar 11 may/ques 1.txt | 22 ++++++++++++++ muskangurjar 11 may/ques 2.txt | 23 +++++++++++++++ muskangurjar 11 may/ques 4.txt | 20 +++++++++++++ muskangurjar 11 may/ques 5.txt | 44 ++++++++++++++++++++++++++++ muskangurjar 11 may/ques 6.txt | 53 ++++++++++++++++++++++++++++++++++ 5 files changed, 162 insertions(+) create mode 100644 muskangurjar 11 may/ques 1.txt create mode 100644 muskangurjar 11 may/ques 2.txt create mode 100644 muskangurjar 11 may/ques 4.txt create mode 100644 muskangurjar 11 may/ques 5.txt create mode 100644 muskangurjar 11 may/ques 6.txt diff --git a/muskangurjar 11 may/ques 1.txt b/muskangurjar 11 may/ques 1.txt new file mode 100644 index 0000000..da99afb --- /dev/null +++ b/muskangurjar 11 may/ques 1.txt @@ -0,0 +1,22 @@ + +#include +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; + } \ No newline at end of file diff --git a/muskangurjar 11 may/ques 2.txt b/muskangurjar 11 may/ques 2.txt new file mode 100644 index 0000000..5c1ab8c --- /dev/null +++ b/muskangurjar 11 may/ques 2.txt @@ -0,0 +1,23 @@ +#include +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; +} + \ No newline at end of file diff --git a/muskangurjar 11 may/ques 4.txt b/muskangurjar 11 may/ques 4.txt new file mode 100644 index 0000000..3774def --- /dev/null +++ b/muskangurjar 11 may/ques 4.txt @@ -0,0 +1,20 @@ +using namespace std; +#include +#include +#include +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< +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; +} diff --git a/muskangurjar 11 may/ques 6.txt b/muskangurjar 11 may/ques 6.txt new file mode 100644 index 0000000..fe097c4 --- /dev/null +++ b/muskangurjar 11 may/ques 6.txt @@ -0,0 +1,53 @@ + +#include +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; +}