From 9997eb6fae11ca927df90c9712ce335b5a3f0cd0 Mon Sep 17 00:00:00 2001 From: Omar Magdy Date: Sun, 29 May 2022 00:05:50 +0200 Subject: Added a new directory codechef which contains some problem I solved on codechef.com --- codechef/luckyFour.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 codechef/luckyFour.cpp (limited to 'codechef/luckyFour.cpp') diff --git a/codechef/luckyFour.cpp b/codechef/luckyFour.cpp new file mode 100644 index 0000000..998b0d5 --- /dev/null +++ b/codechef/luckyFour.cpp @@ -0,0 +1,22 @@ +#include + +using namespace std; + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + int count = 0; + int x; + cin >> x; + while (x) { + int foo = x % 10; + if(foo == 4) count++; + x /= 10; + } + cout << count << endl; + } +} + -- cgit v1.2.3