Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- main(){
- int a[10], max=0, max2=0, panjang;
- cout<<"Panjang Array : ";
- cin>>panjang;
- for(int i=0; i<panjang; i++){
- cout<<"Array ke-"<<i<<" : ";
- cin>>a[i];
- if(a[i]>max)
- {
- max2=max;
- max=a[i];
- }
- else if(a[i]>max2){
- max2=a[i];
- }
- }
- cout<<"Nilai Max ke-1 : "<<max<<endl;
- cout<<"Nilai Max ke-2 : "<<max2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment