Skip to content

Instantly share code, notes, and snippets.

@rodrigoalvesvieira
Created August 11, 2013 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodrigoalvesvieira/6203123 to your computer and use it in GitHub Desktop.
Save rodrigoalvesvieira/6203123 to your computer and use it in GitHub Desktop.
#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;
}
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