Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int nums[5] = {5,4,3,2,4};
- int max = nums[0];
- int smax = nums[1];
- for(int i = 0;i<5;i++){
- if(nums[i]>max){
- smax = max;
- max = nums[i];
- }
- else{
- if(nums[i]<max && nums[i]>smax){
- smax = nums[i];
- }
- }
- }
- cout<<smax<<endl;
- }
Add Comment
Please, Sign In to add comment