Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //valori-panta
- #include <iostream>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- long long cifre[25],n,v[31],x,q,ok1,ok2,mx=-1,mi=9999999999,ct,i,j,c[31];
- int main()
- {
- cin>>n;
- for(int i=1;i<=n;i++)
- cin>>v[i];
- for(i=1;i<=n;i++){
- q=0;
- c[i]=v[i];
- while(c[i]){
- cifre[++q]=c[i]%10;
- c[i]=c[i]/10;
- }
- ok1=1;
- ok2=1;
- reverse(cifre+1,cifre+q+1);
- for(j=1;j<q;j++){
- if(cifre[j]>cifre[j+1]){
- ok1=0;
- break;
- }
- }
- for(j=1;j<q;j++){
- if(cifre[j]<cifre[j+1]){
- ok2=0;
- break;
- }
- }
- //cout<<ok1<<" "<<ok2<<'\n';
- if(ok1||ok2){
- ct++;
- mi=min(mi,v[i]);
- mx=max(mx,v[i]);
- }
- }
- cout<<"Numarul de valori-panta: "<<ct<<'\n';
- cout<<"Cea mai mare valoare-panta: "<<mx<<'\n';
- cout<<"Cea mai mica valoare-panta: "<<mi;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement