Advertisement
rotti321

Recap test info XC

May 4th, 2022
696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. // Online C++ compiler to run C++ program online
  2. #include <iostream>
  3. using namespace std;
  4. int main() {
  5.     // Write C++ code here
  6.     int n,a[1000],i,suma=0,maxim=0,minim=100000000;
  7.     int k=0;
  8.     cin>>n;
  9.     for(i=1;i<=n;i++){
  10.         cin>>a[i];
  11.         if(a[i]>=10 && a[i]<=100){
  12.             suma = suma + a[i]; ///adaug la suma valoarea a[i]
  13.         }
  14.  
  15.         if(maxim<a[i]){
  16.             maxim=a[i];
  17.             k=1;
  18.         }
  19.         else
  20.         {
  21.             if(maxim==a[i]){
  22.                 k++;
  23.             }
  24.         }
  25.         if(minim>a[i]){
  26.             minim=a[i];
  27.         }
  28.     }
  29.     cout <<maxim<<" "<< k;
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement