Advertisement
BORUTO-121

CUONTINGLETTERS

Sep 19th, 2021
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.   int n;
  5.   scanf("%d", &n);
  6.   if (n < 1) {
  7.     printf("Pogresan unos");
  8.     return 1;
  9.   }
  10.  
  11.   FILE *open = fopen("input.txt", "r");
  12.   if (open == NULL) {
  13.     printf("Datoteka input.txt ne postoji");
  14.     return 1;
  15.   }
  16.   FILE *upis = fopen("output.txt", "w");
  17.   int c;
  18.   while ((c = fgetc(open)) != EOF) {
  19.     int slovo = c, brojac = 1, usao=1;
  20.     for (c = fgetc(open); c != EOF && c == slovo; c = fgetc(open), brojac++, usao=1);
  21.  
  22.     if (brojac >= n) {
  23.       int i;
  24.       for (i = 0; i < brojac; i++) {
  25.         fputc(slovo, upis);
  26.       }
  27.     }
  28.     if (c == EOF)
  29.       break;
  30.     if (usao)
  31.       fseek(open, -1, SEEK_CUR);
  32.   }
  33.  
  34.   fclose(open);
  35.   fclose(upis);
  36.   return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement