Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
TwoMax
//g++ 7.4.0 //write and test a function that returns through its reference parameters both the largest and second largest values stored in an array //this code is created by Rezaul Hoque on August 10,2021;contact: jewelmrh@yahoo.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <iostream> using namespace std; const int n=10; void largest(int &,int &,int [],int); void largest(int& max1,int& max2,int a[],int n){ max1 = a[0]; for(int i=0;i<n;i++) if(a[i]>max1) max1=a[i]; max2 = a[0]; for(int i=0;i<n;i++) if(a[i]>max2 && a[i]<max1) max2=a[i]; cout<<"max1: "<<max1<<endl; cout<<"max2: "<<max2<<endl; } int main() { int a[]={10,9,5,8,30,26,32,1,78,20}; int max1,max2; largest(max1, max2,a,10); return 0; }
run
|
edit
|
history
|
help
0
Partition to K Equal Sum Subsets
stl_sizeof
Addition of two matrix **Part 2
CPP - Ex 5
return reference (gcc)
Date n Time Macros
Gatecrasher
euler tour (by pure theory)
Coin changes
te lo paso