Coursera's Algorithmic toolbox assignment solutions( Sum of Two Digits, Maximum Pairwise Product ) :
Problem 1: Sum of Two Digits Solution: (in c++) ( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder) #include < bits/stdc++.h > using namespace std ; int main () { int a , b ; cin >> a >> b ; cout << a + b ; } This code is simple. There's no need for any explanation. Problem 2: Maximum Pairwise Product Solution: (in c++) ( please guys before moving to the solution try it yourself at least 3-4 times , if you really wanna become a good coder) #include< bits/stdc++.h > using namespace std ; int main () { long long n , i ; cin >> n ; long long a [ n ]; for ( i = 0 ; i < n ; i ++) { cin >> a [ i ]; } sort ( a , a + n ); cout <<( a [ n - 1 ]* a [ n - 2 ]); } This code is simple. There's no need for any explanation. Guys , if you have any queries related to a question or need more explan
Comments
Post a Comment