Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int n;
- scanf("%d", &n);
- if (n < 1) {
- printf("Pogresan unos");
- return 1;
- }
- FILE *open = fopen("input.txt", "r");
- if (open == NULL) {
- printf("Datoteka input.txt ne postoji");
- return 1;
- }
- FILE *upis = fopen("output.txt", "w");
- int c;
- while ((c = fgetc(open)) != EOF) {
- int slovo = c, brojac = 1, usao=1;
- for (c = fgetc(open); c != EOF && c == slovo; c = fgetc(open), brojac++, usao=1);
- if (brojac >= n) {
- int i;
- for (i = 0; i < brojac; i++) {
- fputc(slovo, upis);
- }
- }
- if (c == EOF)
- break;
- if (usao)
- fseek(open, -1, SEEK_CUR);
- }
- fclose(open);
- fclose(upis);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement