Created
April 3, 2020 22:19
-
-
Save asa55/50d3fd03aaff19ba47db40708fb6149e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // How do you find the missing number in a given integer array of 1 to 100? | |
| #include <iostream> | |
| #include <algorithm> | |
| int arr[100]; | |
| int main() | |
| { | |
| for( int i = 0; i < 100; ++i ) | |
| arr[i] = i + 1; | |
| arr[49] = 0; | |
| //std::for_each(&arr[0], &arr[99], [](int el){std::cout << el << std::endl;}); | |
| for (int _el : arr) | |
| std::cout << _el << std::endl; | |
| int* missing_num_location = std::find(&arr[0], &arr[99], 0); | |
| std::cout << std::endl << missing_num_location - &arr[0] <<std::endl; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment