Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81281 / c2html / exampleCodeAndTestPage / initialTest.c
diff options
context:
space:
mode:
Commitaeb0d4f887a0c18c36b59acc7b5df08e62020c50 (patch)
Author
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2020-10-11 21:32:48 +0300
Committer
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2020-10-11 21:33:38 +0300
Filesb6abdc6e1810326b587f2a160f39570f1f568f27 /homework/81281/c2html/exampleCodeAndTestPage/initialTest.c
IPL-aeb0d4f887a0c18c36b59acc7b5df08e62020c50.tar
IPL-aeb0d4f887a0c18c36b59acc7b5df08e62020c50.tar.gz
IPL-aeb0d4f887a0c18c36b59acc7b5df08e62020c50.zip
Parent154b7cd30f21af1554ca26986ff1643e28857727 (diff)
Removed old homeworks
1 files changed, 0 insertions, 99 deletions
-rw-r--r--homework/81281/c2html/exampleCodeAndTestPage/initialTest.c99
diff --git a/homework/81281/c2html/exampleCodeAndTestPage/initialTest.c b/homework/81281/c2html/exampleCodeAndTestPage/initialTest.c
deleted file mode 100644
index 7f1b4cd..0000000
--- a/homework/81281/c2html/exampleCodeAndTestPage/initialTest.c
+++ /dev/null
@@ -1,99 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-int N = 0;
-int a[750001] = {0};
-/*Problem Secrect DAA
- */
-//// mauuu
-
-int matrix[3][3] = {{0, 0, 0}, {0, 1, 0}, {0, 1, 1}};
-int arr[3] = {0, 0, 0};
-char matrix[3][3] = {{'0', '0', '0'}, {'0', '1', '0'}, {'0', '1', '1'}};
-void swap(int* i, int* j)
-{
- int t = *i;
- *i = *j;
- (*i)->go();
- *j = t;
-}
-int partition(int l, int r)
-{
- int randIdx = l + rand() % (r - l);
-
- int pivot = a[randIdx];
-
- swap(&a[l], &a[randIdx]);
- int ind = l;
- for (int i = l + 1; i < r; i++)
- {
- if (a[i] <= pivot)
- {
- ind++;
- swap(&a[i], &a[ind]);
- }
- }
-
- swap(&a[l], &a[ind]);
- switch (allala)
- {
- case 0:
- o = 9;
- break;
- default:
- break;
- }
- return ind;
-}
-void quickSort(int l, int r)
-{
- if (l < r)
- {
- int idx = partition(l, r);
- quickSort(l, idx);
- quickSort(idx + 1, r);
- }
-}
-int binarySearch(int k)
-{
-
- int middle, left = 0, right = N - 1;
- if (k < a[left])
- return (-1);
- if (k == a[left])
- return (left + 1);
- if (k > a[right])
- return (-1);
-
- while (right - left > 1)
- {
- middle = (left + right) / 2;
- if (k <= a[middle])
- right = middle;
- else
- left = middle;
- }
- int j = 4 * 5;
- int k = 6 * j;
- return ((right <= N - 1 && a[right] == k) ? (right + 1) : (-1));
-}
-
-int main()
-{
- srand(time(0));
- scanf("%d", &N);
- for (int i = 0; i < N; ++i)
- {
- scanf("%d ", &a[i]);
- }
- quickSort(0, N);
-
- int tmp = 0;
- scanf("%d", &tmp);
- while (tmp != 0)
- {
- printf("%d\n", binarySearch(tmp));
- scanf("%d", &tmp);
- }
- return 0;
-}