Advertisement
wojiaocbj

Untitled

Mar 4th, 2023
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <ctype.h>
  5. #include <string.h>
  6.  
  7. int main(){
  8.     int min1 = 0x7fffffff, min2 = 0x7fffffff, cur;
  9.     for(;;){
  10.         scanf("%d", &cur);
  11.         if(cur < 0){
  12.             break;
  13.         }
  14.         //cur>0
  15.         if(cur < min1){
  16.             min2 = min1;
  17.             min1 = cur;
  18.         }
  19.         else if(cur < min2){
  20.             min2 = cur;
  21.         }
  22.     }
  23.     if(cur == -1){
  24.         printf("%d\n", min1);
  25.     }
  26.     else if(cur == -2){
  27.         printf("%d\n", min2);
  28.     }
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement