Created
May 30, 2019 01:51
-
-
Save AhmedMourad0/88d827042526e0fe71e89b62195c4a5c to your computer and use it in GitHub Desktop.
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<module classpath="CMake" type="CPP_MODULE" version="4" /> |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="Encoding" addBOMForNewFiles="with NO BOM" /> | |
</project> |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" /> | |
<component name="JavaScriptSettings"> | |
<option name="languageLevel" value="ES6" /> | |
</component> | |
</project> |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectModuleManager"> | |
<modules> | |
<module fileurl="file://$PROJECT_DIR$/.idea/Dummy1.iml" filepath="$PROJECT_DIR$/.idea/Dummy1.iml" /> | |
</modules> | |
</component> | |
</project> |
This file contains 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
cmake_minimum_required(VERSION 3.13) | |
project(Dummy1) | |
set(CMAKE_CXX_STANDARD 14) | |
add_executable(Dummy1 main.cpp) |
This file contains 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
#include <iostream> | |
#include <string> | |
using namespace std; | |
int max(const int arr[], int length) { | |
if (length <= 0) | |
return -1; | |
int max = arr[0]; | |
for (int i = 0; i < length; ++i) | |
if (arr[i] > max) | |
max = arr[i]; | |
return max; | |
} | |
int min(const int arr[], int length) { | |
if (length <= 0) | |
return -1; | |
int min = arr[0]; | |
for (int i = 0; i < length; ++i) | |
if (arr[i] < min) | |
min = arr[i]; | |
return min; | |
} | |
string toString(int arr[], int length) { | |
string str = "["; | |
for (int i = 0; i < length; ++i) { | |
str += to_string(arr[i]); | |
if (i < length - 1) | |
str += ", "; | |
else | |
str += "]"; | |
} | |
return str; | |
} | |
int main() { | |
const int length = 5; | |
int numbers[length]; | |
cout << "Enter the " << length << " numbers:"; | |
for (int i = 0; i < length; ++i) | |
cin >> numbers[i]; | |
cout << "numbers" << toString(numbers, length) << endl | |
<< "max: " << max(numbers, length) << endl | |
<< "min: " << min(numbers, length) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment