Created
August 11, 2013 02:23
-
-
Save rodrigoalvesvieira/6203123 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
#include <iostream> | |
#include <stdexcept> | |
using namespace std; | |
int divide(int A, int B); | |
int main() | |
{ | |
int A, B; | |
cout << "Welcome do the marvelous divider!\n" << endl << endl; | |
cout << "Enter a number A: " << endl; | |
cin >> A; | |
cout << "Now enter a number B: " << endl; | |
cin >> B; | |
cout << "The result is " << divide(A, B) << endl; | |
return 0; | |
} | |
int divide(int A, int B) | |
{ | |
if (B == 0) throw std::invalid_argument("Denominator can't be 0!"); | |
return A/B; | |
} |
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
ar = [10, 39, 41, 20, 30, 40] | |
def max(array) | |
res = 0 | |
array.each do |number| | |
if (number > res) | |
res = number | |
end | |
end | |
return res | |
end | |
puts max(ar) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment