Advertisement
18126

ExampleTestNo1Ex3

Mar 22nd, 2022
989
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define print printf("%d\n", num)
  6.  
  7. int main(int args, char *argv[]) {
  8.     int num;
  9.     for(int i = 1; i < args; i++) {
  10.         while(scanf("%d", &num) != EOF) {
  11.             if(args == 1) {
  12.                 print;
  13.             } else if( (strcmp(argv[i], "-evens") == 0 || strcmp(argv[i], "-e") == 0) && num%2 == 0) {
  14.                 print;
  15.             } else if( (strcmp(argv[i], "-odds") == 0 || strcmp(argv[i], "-o") == 0) && num%2 != 0) {
  16.                 print;
  17.             } else if( (strcmp(argv[i], "-positives") == 0 || strcmp(argv[i], "-p") == 0) && num >= 0) {
  18.                 print;
  19.             } else if( (strcmp(argv[i], "-negatives") == 0 || strcmp(argv[i], "-n") == 0) && num < 0) {
  20.                 print;
  21.             } else if( (strcmp(argv[i], "-range") == 0 || strcmp(argv[i], "-r") == 0) && num >= atoi(argv[2]) && num <= atoi(argv[3])) {
  22.                 print;
  23.             }
  24.         }
  25.     }
  26.    
  27.     return 0;
  28. }
  29.  
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement