diff --git a/ex1/Exercise_1_Task_1 b/ex1/Exercise_1_Task_1 new file mode 100644 index 0000000000000000000000000000000000000000..51234e35341efe6aca289a3f830bc2582d26d15c --- /dev/null +++ b/ex1/Exercise_1_Task_1 @@ -0,0 +1,10 @@ +Compilation commad: gcc T1.c -o T1 + +Final Output: + +Search for target 5 +could not find target +Search for target 1 +target has been found 1000 + + diff --git a/ex1/Exercise_1_Task_3 b/ex1/Exercise_1_Task_3 new file mode 100644 index 0000000000000000000000000000000000000000..34c89e8b6e6390487c8c08a06a9eff489896a8fd --- /dev/null +++ b/ex1/Exercise_1_Task_3 @@ -0,0 +1,7 @@ +Output report: +In all three cases the program takes an input array that is : 5 9 1 2 3. +In cases 1 and 3 the array is sorted in the ascendant order with an output being 1 2 3 5 9. +Whereas in case 2 the array is sorted in the descending order with an output being: 9 5 3 2 1 + +When compiling L1 the -c option says not to run the linker to get object files as output. +Assembling and Linking diff --git a/ex1/Makefile b/ex1/Makefile index a2fbb7abb48df37bed5388965ffbe0507da261b4..40f8a2872b12539eded4a294f49f58b707aff94f 100644 --- a/ex1/Makefile +++ b/ex1/Makefile @@ -7,4 +7,6 @@ L2: L3: gcc -o t3_case3.o T3.c l1.c clean: - rm *.o \ No newline at end of file + rm *.o + + diff --git a/ex1/T1 b/ex1/T1 new file mode 100755 index 0000000000000000000000000000000000000000..cb39e4a78e24f356ae464884d361cabeda8c44d2 Binary files /dev/null and b/ex1/T1 differ diff --git a/ex1/T1.c b/ex1/T1.c index 71b497e4fa4de469151566d717cf36071b16d7f4..61226f66ab745cb3943857bfb3ab040f1136e5ba 100644 --- a/ex1/T1.c +++ b/ex1/T1.c @@ -1,8 +1,27 @@ #include<stdlib.h> #include<stdio.h> -int get_frequency(int *, int, int); -void display_results(int param1); +int get_frequency(int * in, int size, int target){ + int counter=0; + for( int i=0; i<size; i++){ + if(in[i]==target){ + counter++; + } + } + return counter==0?-1:counter; +} + +void display_results(int param1){ + switch(param1){ + case -1: + printf("could not find target\n"); + break; + default: + printf("target has been found %d\n", param1); + } +} + + int main(int argc, char *argv[]){ int total_size=1000; @@ -29,15 +48,5 @@ int main(int argc, char *argv[]){ return 0; } -int get_frequency(int * in, int size, int target){ - // TODO implement get_get_frequency here -} -void display_results(int param1){ - switch(param1){ - case -1: - printf("could not find target\n"); - break; - default: - printf("target has been found %d\n", param1); - } -} + + diff --git a/ex1/g b/ex1/g new file mode 100644 index 0000000000000000000000000000000000000000..a8194547ea1a3b2dad8e21561622f7393b1cc0fb Binary files /dev/null and b/ex1/g differ diff --git a/ex1/libmylib1.a b/ex1/libmylib1.a index 796f089e64151efdb0be24117db7a48fc2c362a8..39f57176bcacfe83ddd2fe61a4701d970c5dd5d9 100644 Binary files a/ex1/libmylib1.a and b/ex1/libmylib1.a differ diff --git a/ex1/libmylib2.a b/ex1/libmylib2.a new file mode 100644 index 0000000000000000000000000000000000000000..ebde3097123f7d96c49b9ed7feb2ecafc9536515 Binary files /dev/null and b/ex1/libmylib2.a differ diff --git a/ex1/t3_case1.o b/ex1/t3_case1.o new file mode 100755 index 0000000000000000000000000000000000000000..859dada96cce4f63fedfd458bdb11953fcd06b3a Binary files /dev/null and b/ex1/t3_case1.o differ diff --git a/ex1/t3_case3.o b/ex1/t3_case3.o new file mode 100755 index 0000000000000000000000000000000000000000..859dada96cce4f63fedfd458bdb11953fcd06b3a Binary files /dev/null and b/ex1/t3_case3.o differ