Advertisement
informaticage

Esercizio 2.1 C - UniversApp

Aug 31st, 2022
868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | Source Code | 0 0
  1. #include <stdbool.h>
  2. #include <stdio.h>
  3.  
  4. int main() {
  5.   int previus, current;
  6.  
  7.   scanf("%d", &previus);
  8.   scanf("%d", &current);
  9.  
  10.   // true if increasing
  11.   // false if decreasing
  12.   bool isIncreasing = current >= previus;
  13.  
  14.   if (isIncreasing) {
  15.     // Increasing
  16.     while (isIncreasing) {
  17.       previus = current;
  18.       scanf("%d", &current);
  19.       isIncreasing = current >= previus;
  20.     }
  21.   } else {
  22.     // Decreasing
  23.     while (!isIncreasing) {
  24.       previus = current;
  25.       scanf("%d", &current);
  26.       isIncreasing = current >= previus;
  27.     }
  28.   }
  29.  
  30.   return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement