Advertisement
Josif_tepe

Untitled

May 27th, 2024
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4.  
  5. int main(int argc, char * argv[]) {
  6.     if(argc < 2) {
  7.         printf("Vlezna datoteka se vnesuva preku komandna linija\n");
  8.         return 0;
  9.     }
  10.     FILE * in = fopen(argv[1], "r");
  11.     if(in == NULL) {
  12.         printf("Vnesovte ne validna vlezna datoteka\n");
  13.         return 0;
  14.     }
  15.     char niza[2000];
  16.     char c;
  17.     int j = 0;
  18.     while((c = fgetc(in)) != EOF) {
  19.         if(isalnum(c)) {
  20.             niza[j] = c;
  21.             j++;
  22.         }
  23.         else {
  24.             int cifri = 0, bukvi = 0;
  25.             for(int i = 0; i < j; i++) {
  26.                 if(isdigit(niza[i])) {
  27.                     cifri++;
  28.                 }
  29.                 if(isalpha(niza[i])) {
  30.                     bukvi++;
  31.                 }
  32.             }
  33.             if(cifri >= 2 && bukvi >= 1) {
  34.                 for(int i = 0; i < j; i++) {
  35.                     printf("%c", niza[i]);
  36.                 }
  37.                 printf("\n");
  38.             }
  39.             j = 0;
  40.         }
  41.     }
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement