
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Possible Timings in C++
In this problem, we are given two-digit timing using a glow digit display or seven-segment display (as in calculator). Our task is to calculate the possibility of occurrence of other timings that can occur by glowing or deleting one bit of the display.
Seven-segment display is a special display that is used to display digits by glowing lines of the display.
Sample of the seven-segment display is −
Let’s take an example to understand the problem,
Input − 7 5
Output −
Explanation − For 7, 5 numbers can be used to replace it. They are 9, 3, 8, 0, 7. For 5, 4 numbers can be used to replace it. So, the total number of ways would be 5*4 = 20.
To solve this problem, we will have to store all the elements that can be created by the glowing or unglowing one rod of the display. The solution will be the product of values for both of the digits of the timing.
Example
Program to show the implementation of our solution
#include <iostream> using namespace std; int num[10] = { 2, 7, 2, 3, 3, 4, 2, 5, 1, 2 }; int AllPossibleTimmings(int timing) { return ((num[timing/10]*num[timing%10])); } int main() { int timing = 71; cout<<"All Possible timings from "<<timing<<" are : "<<AllPossibleTimmings(timing); return 0; }
Output
All Possible timings from 71 are : 35