Josif_tepe

Untitled

Jun 2nd, 2026
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.12 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6.  
  7. int main(int argc, char * argv[]) {
  8.     if(argc < 3) {
  9.         printf("Nema dovolno argumenti\n");
  10.         return 0;
  11.     }    
  12.  
  13.     FILE * in = fopen(argv[1], "r");
  14.     FILE * out = fopen(argv[2], "w");
  15.  
  16.     if(in == NULL || out == NULL) {
  17.         printf("Ne postojat datotekite\n");
  18.         return 0;
  19.     }
  20.  
  21.    char niza[2000];
  22.    int i = 0;
  23.    
  24.    char c;
  25.  
  26.    while((c = fgetc(in)) != EOF) {
  27.     if(c == '\n') {
  28.         for(int j = 0; j < i; j++) {
  29.             if(isdigit(niza[j])) {
  30.                 int x = niza[j] - '0';
  31.                 j++;
  32.                 while(x > 0 && j < i) {
  33.                     fprintf(out, "%c", niza[j]);
  34.                     j++;
  35.                     x--;
  36.                 }
  37.             }
  38.         }
  39.         i = 0;
  40.         niza[0] = '\0';
  41.     }
  42.     else {
  43.         niza[i] = c;
  44.         i++;
  45.     }
  46.  
  47.  
  48.    }
  49.     return 0;
  50. }
  51. /*stanarite od zgrada 3 i od zgrada 5, gjubreto da go frlaat kaj zgrada 7 kontejnerite.
  52. Dodeka pak, zgradite 6 i 8, gjubreto da go frlaat kaj zgrada 9 kontejnerie*/
  53.  
Advertisement
Add Comment
Please, Sign In to add comment