I have to write a C++ function where the input is a 12 digit numeric string. I have to find the range which is also stored in string arrays.
For Example,
Range array [10]:
1 - 111115555522 - 111225555521
2 - 111225555522 - 111335555521
3 - 111335555522 - 111445555521
4 - 111445555522 - 111555555521
5 - 111555555522 - 111665555521
6 - 111665555522 - 111775555521
7 - 111775555522 - 111885555521
8 - 111885555522 - 111995555521
9 - 111995555522 - 112005555521
10- 112005555522 - 113005555521
Input - 111555512440
Output - the number belongs to range - 5
I have used "long long" data type for numerical ranges and the input as well and accomplished it. But since I have to also maintain performance, can somebody give me a better idea to make it such that input value remains string as well as the ranges will also remain in string?
P.S.: I am fine with the use of "char" pointers instead of std::string.
Aucun commentaire:
Enregistrer un commentaire