diff --git a/ASD_Task_1.depend b/ASD_Task_1.depend index f6e48bd..b8d7ac5 100644 --- a/ASD_Task_1.depend +++ b/ASD_Task_1.depend @@ -7,3 +7,6 @@ 1516168119 c:\users\andityaarifianto\documents\github\asd_task_1\asd_task_1.h +1579880206 source:c:\users\computer\documents\github\asd_task_1\main.cpp + + diff --git a/ASD_Task_1.layout b/ASD_Task_1.layout index b374acb..24aea37 100644 --- a/ASD_Task_1.layout +++ b/ASD_Task_1.layout @@ -4,7 +4,7 @@ - + diff --git a/bin/Debug/ASD_Task_1.exe b/bin/Debug/ASD_Task_1.exe index bb9d49d..3887047 100644 Binary files a/bin/Debug/ASD_Task_1.exe and b/bin/Debug/ASD_Task_1.exe differ diff --git a/main.cpp b/main.cpp index f439d60..02dbed7 100644 --- a/main.cpp +++ b/main.cpp @@ -4,6 +4,7 @@ using namespace std; /** WRITE DOWN YOUR INFORMATION HERE */ + string name = ""; // put your name here string ID = ""; // put your student id here int group_id = 0; // your Group Number here (1-8) @@ -102,10 +103,8 @@ void insert_last(int arr[], int &n, int x) { */ // YOUR CODES HERE - //----------------------- - - - //----------------------- + arr[n] = x; + n++; } @@ -118,10 +117,16 @@ void search_and_delete(int arr[], int &n, int x) { */ // YOUR CODES HERE - //----------------------- - - //----------------------- + for (int i = 0; i < n; i++) { + if (arr[i] == x) { + arr[i] = 0; + for (int j = i ; j < n ; j++) { + swap(arr[j], arr[j+1]); + } + n--; + } + } } @@ -213,10 +218,10 @@ void view_data_2(int arr[], int n) { */ // YOUR CODES HERE - //----------------------- - - - //----------------------- + for (int i = n-1; i >= 0 ; i--) { + cout << arr[i] << " "; + } + cout << endl; } diff --git a/obj/Debug/main.o b/obj/Debug/main.o index d35aeda..7ff99bf 100644 Binary files a/obj/Debug/main.o and b/obj/Debug/main.o differ