From 3b8746b535f334f3f5111a25d73595d9b5e23bf8 Mon Sep 17 00:00:00 2001 From: NaufalRezkyA Date: Wed, 22 Jan 2020 19:57:06 +0700 Subject: [PATCH 1/8] Update main.cpp Soal H dan J --- main.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index f439d60..2bea8ce 100644 --- a/main.cpp +++ b/main.cpp @@ -119,8 +119,17 @@ void search_and_delete(int arr[], int &n, int x) { // YOUR CODES HERE //----------------------- - - + for (int i = 0; i < n; i++) + { + if (arr[i] == x) + { + while (i < n) + { + arr[i] = arr[i + 1]; + } + n = n - 1; + } + } //----------------------- } From a2fa12180da038ba1112dfd45b801cce8ddeab15 Mon Sep 17 00:00:00 2001 From: NaufalRezkyA Date: Thu, 23 Jan 2020 14:13:21 +0700 Subject: [PATCH 2/8] Update main.cpp Fix tugas --- main.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 2bea8ce..7e3ca39 100644 --- a/main.cpp +++ b/main.cpp @@ -4,9 +4,9 @@ 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) +string name = "Naufal Rezky Ananda"; // put your name here +string ID = "1301190478"; // put your student id here +int group_id = 7; // your Group Number here (1-8) /** FUNCTIONS LIST, DO NOT MODIFY THESE */ @@ -103,7 +103,8 @@ void insert_last(int arr[], int &n, int x) { // YOUR CODES HERE //----------------------- - + arr[n]=x; + n=n+1; //----------------------- } @@ -119,13 +120,16 @@ void search_and_delete(int arr[], int &n, int x) { // YOUR CODES HERE //----------------------- + int temp; for (int i = 0; i < n; i++) { if (arr[i] == x) { while (i < n) { + temp = arr[i]; arr[i] = arr[i + 1]; + arr[i+1] = temp; } n = n - 1; } From 3efa2f9b4f48afbd360ace7eee8de4bbfa4174a2 Mon Sep 17 00:00:00 2001 From: BerlianaShafa <59946995+BerlianaShafa@users.noreply.github.com> Date: Fri, 24 Jan 2020 14:53:43 +0700 Subject: [PATCH 3/8] 1301194181 Berliana Shafa W. --- main.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 7e3ca39..13fe3a4 100644 --- a/main.cpp +++ b/main.cpp @@ -125,13 +125,11 @@ void search_and_delete(int arr[], int &n, int x) { { if (arr[i] == x) { - while (i < n) + for (int j = i;j < (n - 1); j++ { - temp = arr[i]; - arr[i] = arr[i + 1]; - arr[i+1] = temp; + arr[j] = arr[j + 1]; } - n = n - 1; + n--; } } //----------------------- @@ -165,6 +163,7 @@ string count_and_sum(int arr[], int n) { //----------------------- + //----------------------- return ""; } From cfa665603d92ae763eede0199e19732c0f4319d5 Mon Sep 17 00:00:00 2001 From: michellecfb Date: Fri, 24 Jan 2020 21:07:17 +0700 Subject: [PATCH 4/8] Update main.cpp Michelle C F Bara_1301194405 --- main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 7e3ca39..78dd424 100644 --- a/main.cpp +++ b/main.cpp @@ -125,13 +125,13 @@ void search_and_delete(int arr[], int &n, int x) { { if (arr[i] == x) { - while (i < n) + for (int j = i; j < (n-1); j++) { - temp = arr[i]; - arr[i] = arr[i + 1]; - arr[i+1] = temp; + int temp = arr[j]; + arr[j] = arr[j + 1]; + arr[j+1] = temp; } - n = n - 1; + n--; } } //----------------------- From 1a11cd97ad0c4ddb0f66b7625c93e8e4ec48cbf8 Mon Sep 17 00:00:00 2001 From: michellecfb Date: Fri, 24 Jan 2020 21:13:16 +0700 Subject: [PATCH 5/8] Update main.cpp --- main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 78dd424..c00642c 100644 --- a/main.cpp +++ b/main.cpp @@ -4,8 +4,8 @@ using namespace std; /** WRITE DOWN YOUR INFORMATION HERE */ -string name = "Naufal Rezky Ananda"; // put your name here -string ID = "1301190478"; // put your student id here +string name = "Michelle Caecilia Fiorenza Bara"; // put your name here +string ID = "1301194405"; // put your student id here int group_id = 7; // your Group Number here (1-8) From 2f376508f06dbcc99b73dcb731fa09824337666d Mon Sep 17 00:00:00 2001 From: GhifariADR <59873588+GhifariADR@users.noreply.github.com> Date: Fri, 24 Jan 2020 22:02:08 -0800 Subject: [PATCH 6/8] Update main.cpp --- main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 13fe3a4..1644b77 100644 --- a/main.cpp +++ b/main.cpp @@ -4,8 +4,8 @@ using namespace std; /** WRITE DOWN YOUR INFORMATION HERE */ -string name = "Naufal Rezky Ananda"; // put your name here -string ID = "1301190478"; // put your student id here +string name = "Muhammad Ghifari Adrian"; // put your name here +string ID = "1301194034"; // put your student id here int group_id = 7; // your Group Number here (1-8) From 6433ece357dd38cca2c8ae655436fbb6c5a8eaf1 Mon Sep 17 00:00:00 2001 From: GhifariADR <59873588+GhifariADR@users.noreply.github.com> Date: Fri, 24 Jan 2020 22:04:28 -0800 Subject: [PATCH 7/8] Update main.cpp --- main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.cpp b/main.cpp index 1644b77..d6ca46e 100644 --- a/main.cpp +++ b/main.cpp @@ -128,6 +128,8 @@ void search_and_delete(int arr[], int &n, int x) { for (int j = i;j < (n - 1); j++ { arr[j] = arr[j + 1]; + arr[j+1] = arr[j+1]; + arr[j+1] = temp; } n--; } From d109cd8323fc3052d86cf5994ef83a4d7d593237 Mon Sep 17 00:00:00 2001 From: NaufalRezkyA <56570051+NaufalRezkyA@users.noreply.github.com> Date: Sat, 25 Jan 2020 15:43:55 +0700 Subject: [PATCH 8/8] Update main.cpp --- main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index c956859..e749938 100644 --- a/main.cpp +++ b/main.cpp @@ -5,8 +5,8 @@ using namespace std; /** WRITE DOWN YOUR INFORMATION HERE */ -string name = "Muhammad Ghifari Adrian"; // put your name here -string ID = "1301194034"; // put your student id here +string name = " "; // put your name here +string ID = " "; // put your student id here int group_id = 7; // your Group Number here (1-8)