Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- int main(int argc, char * argv[]) {
- if(argc < 3) {
- printf("Nema dovolno argumenti\n");
- return 0;
- }
- FILE * in = fopen(argv[1], "r");
- FILE * out = fopen(argv[2], "w");
- if(in == NULL || out == NULL) {
- printf("Ne postojat datotekite\n");
- return 0;
- }
- char niza[2000];
- int i = 0;
- char c;
- while((c = fgetc(in)) != EOF) {
- if(c == '\n') {
- for(int j = 0; j < i; j++) {
- if(isdigit(niza[j])) {
- int x = niza[j] - '0';
- j++;
- while(x > 0 && j < i) {
- fprintf(out, "%c", niza[j]);
- j++;
- x--;
- }
- }
- }
- i = 0;
- niza[0] = '\0';
- }
- else {
- niza[i] = c;
- i++;
- }
- }
- return 0;
- }
- /*stanarite od zgrada 3 i od zgrada 5, gjubreto da go frlaat kaj zgrada 7 kontejnerite.
- Dodeka pak, zgradite 6 i 8, gjubreto da go frlaat kaj zgrada 9 kontejnerie*/
Advertisement
Add Comment
Please, Sign In to add comment