Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81281 / c2html
diff options
context:
space:
mode:
2 files changed, 0 insertions, 99 deletions
-rw-r--r--homework/81281/c2html/executeProgram.sh12
-rw-r--r--homework/81281/c2html/test.c87
diff --git a/homework/81281/c2html/executeProgram.sh b/homework/81281/c2html/executeProgram.sh
deleted file mode 100644
index bc02714..0000000
--- a/homework/81281/c2html/executeProgram.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-echo -n "Please enter the name of the C file you wish to highlight:"
-read fileName
-echo $fileName
-if ! [[ $fileName == *.c\n ]]; then
- base=`pwd`"/c2html.pl"
- PL=swipl
- exec $PL -q -f "$base" "$fileName"
-else
- echo "Not a correct C filename!"
-fi
diff --git a/homework/81281/c2html/test.c b/homework/81281/c2html/test.c
deleted file mode 100644
index 7176890..0000000
--- a/homework/81281/c2html/test.c
+++ /dev/null
@@ -1,87 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-int N = 0;
-int a[750001] = {0};
-/*Problem Secrect DAA*/
-//// mauuu
-
-void swap(int* i, int* j)
-{
- int t = *i;
- *i = *j;
- *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]);
- 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;
- }
- 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;
-}