Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. //valori-panta
  2. #include <iostream>
  3. #include <cmath>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. long long cifre[25],n,v[31],x,q,ok1,ok2,mx=-1,mi=9999999999,ct,i,j,c[31];
  9. int main()
  10. {
  11. cin>>n;
  12. for(int i=1;i<=n;i++)
  13. cin>>v[i];
  14. for(i=1;i<=n;i++){
  15. q=0;
  16. c[i]=v[i];
  17. while(c[i]){
  18. cifre[++q]=c[i]%10;
  19. c[i]=c[i]/10;
  20. }
  21. ok1=1;
  22. ok2=1;
  23. reverse(cifre+1,cifre+q+1);
  24. for(j=1;j<q;j++){
  25. if(cifre[j]>cifre[j+1]){
  26. ok1=0;
  27. break;
  28. }
  29. }
  30. for(j=1;j<q;j++){
  31. if(cifre[j]<cifre[j+1]){
  32. ok2=0;
  33. break;
  34. }
  35. }
  36. //cout<<ok1<<" "<<ok2<<'\n';
  37. if(ok1||ok2){
  38. ct++;
  39. mi=min(mi,v[i]);
  40. mx=max(mx,v[i]);
  41. }
  42. }
  43. cout<<"Numarul de valori-panta: "<<ct<<'\n';
  44. cout<<"Cea mai mare valoare-panta: "<<mx<<'\n';
  45. cout<<"Cea mai mica valoare-panta: "<<mi;
  46.  
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement