Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
1 files changed, 3 insertions, 2 deletions
-rw-r--r--Sem. 03/Solutions/03. Remove_Middle_Digits.cpp5
diff --git a/Sem. 03/Solutions/03. Remove_Middle_Digits.cpp b/Sem. 03/Solutions/03. Remove_Middle_Digits.cpp
index 5874ec4..c22a028 100644
--- a/Sem. 03/Solutions/03. Remove_Middle_Digits.cpp
+++ b/Sem. 03/Solutions/03. Remove_Middle_Digits.cpp
@@ -7,12 +7,13 @@ int main()
int n;
cin >> n;
- int digits = 0, reversedN;
+ int digits = 0;
for (int i = n; i != 0; i /= 10)
digits++;
- int tenToTheHalf = 1; // ten to the power of digits to take from each end
int digitsToTakeFromEachEnd = digits / 2 + (digits % 2 - 1);
+ int tenToTheHalf = 1; // ten to the power of digits to take from each end
+
for (int i = 0; i < digitsToTakeFromEachEnd; i++)
tenToTheHalf *= 10;