-
Notifications
You must be signed in to change notification settings - Fork 165
feat(verify.cpp): implemented array search #455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,10 +9,36 @@ The number 3 is [not] present in the array. | |
| #include <iostream> | ||
| using namespace std; | ||
|
|
||
| bool isPresent(int* Arr, const size_t& size, const int& n); | ||
| void printOutput(bool present); | ||
|
|
||
| bool isPresent(int* Arr, const size_t& size, const int& n){ | ||
| for(size_t i = 0; i < size ; i++){ | ||
| if(Arr[i] == n){ | ||
| return true;// FOUND!! | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| void printOutput(bool present){ | ||
| cout << "The number is "; | ||
| if(!present){ //not present | ||
| cout << "not "; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not bad 👍 |
||
| cout << "present in the array." << endl; | ||
| } | ||
|
|
||
| int main() | ||
| { | ||
| // placeholder | ||
| int N[10] = {3, 4, 5, 1, 2, 3, 4, 9, 13, 0}; | ||
| int N[] = {3, 4, 5, 1, 2, 3, 4, 9, 13, 0}; | ||
| size_t arrSize = 10; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dimensione t mi è sempre sembrato poco chiaro e significativo come "nome" del tipo |
||
| int numInput; | ||
|
|
||
| cout << "Insert number: " << endl; | ||
| cin >> numInput; | ||
|
|
||
| printOutput( isPresent( N , arrSize , numInput) ); | ||
|
|
||
| return 0; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.