Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int temp, cneg, cpos, ctpos=0, ctneg=0;
  7.     for (int i=0; i<18; i++){
  8.         printf ("Ingrese una temperatura distinta de 0:");
  9.         scanf ("%d", &temp);
  10.         if (temp>0){
  11.             cneg=0;
  12.             cpos++;
  13.             if (cpos>2){
  14.                 ctpos++;
  15.             }
  16.         }
  17.         else{
  18.             cpos=0;
  19.             cneg++;
  20.             if (cneg>2){
  21.                 ctneg++;
  22.             }
  23.         }
  24.     }
  25.  
  26.     printf ("Se ingresaron %d ternas positivas y %d ternas negativas", ctpos, ctneg);
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement