Advertisement
Eduardo_Braz

Sequência ordenada em C

Nov 14th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.     int t, i;
  5.     double n, sequencia,n2;
  6.     n2 = 0;
  7.     sequencia = 0;
  8.    
  9.     scanf("%d", &t);
  10.  
  11.     for (i = 0; i < t; i++)
  12.     {
  13.         scanf("%lf", &n);
  14.         printf("%lf ", n);        
  15.         if(n > n2 || n < n2){
  16.             sequencia++;
  17.         }
  18.         n2 = n;
  19.     }
  20.     if(n == sequencia){
  21.         printf("\nODERNADA");
  22.     }
  23.     else{
  24.         printf("\nDESORDENADA");
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement