summaryrefslogtreecommitdiff
path: root/if.cpp
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-07-28 12:52:38 +0200
committerOskar <[email protected]>2024-07-28 12:52:38 +0200
commit5aac3c3f8bcfef0b2aad28d91d87b9ebf1d5e7df (patch)
tree38736b9f0c57f69e272121e0fc1f3969bb7468e2 /if.cpp
first commit
Diffstat (limited to 'if.cpp')
-rw-r--r--if.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/if.cpp b/if.cpp
new file mode 100644
index 0000000..c566370
--- /dev/null
+++ b/if.cpp
@@ -0,0 +1,21 @@
+#include <iostream>
+
+int main () {
+
+ int currVal = 0, val = 0, counter = 1;
+ if(std::cin >> currVal) {
+ while(std::cin >> val) {
+ if (currVal == val) {
+ ++counter;
+ } else {
+ std::cout << "You entered " << currVal << " " << counter << " times." << std::endl;
+ currVal = val;
+ counter = 1;
+ }
+
+ }
+ std::cout << "You entered " << currVal << " " << counter << " times." << std::endl;
+ }
+
+ return 0;
+}