From 6a8154ad7f2cbfbb2ae4f2ddda1cd0db0e430e44 Mon Sep 17 00:00:00 2001 From: Kamen Mladenov Date: Tue, 2 Apr 2024 16:49:21 +0300 Subject: [w5/ex1] Updated logic for patient removal --- week05/Exercise1.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'week05/Exercise1.cpp') diff --git a/week05/Exercise1.cpp b/week05/Exercise1.cpp index 28fc290..7fdaa7d 100644 --- a/week05/Exercise1.cpp +++ b/week05/Exercise1.cpp @@ -24,9 +24,10 @@ public: patients[lastIndex++] = newPatient; } - // По принцип логиката трябва да е по-сложна, да се маха пациент по индекс и - // след това да се изместват останалите, но за целите на задачата това не е нужно - void RemovePatient() { + void RemovePatient(int index) { + for (int i = index; i < lastIndex - 1; i++) { + patients[i] = patients[i+1]; + } lastIndex--; } }; -- cgit v1.2.3