Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char *argv[])
- {
- int vobroj=0;
- int brojac=0;
- int broj=0;
- int suma=0;
- FILE* dat1;
- FILE* dat2;
- dat2=fopen("rezultat.txt", "w");
- char c;
- if((dat1=fopen(argv[1], "r"))==NULL){
- fputc(c, dat2);
- return -1;}
- while((c=fgetc(dat1))!=EOF){
- fprintf(dat2, "%c", c);
- if(isdigit(c)){
- if(vobroj==0){
- vobroj=1;
- broj=c-'0';
- brojac++;
- }
- else{
- broj*=10;
- broj+=c-'0';
- }
- }
- else{
- if(vobroj)
- //fprintf("%d", broj);
- vobroj=0;
- suma+=broj;
- broj=0;
- }
- }
- printf("Prosekot e %d", suma/(float)brojac);
- fclose(dat1);
- fclose(dat2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement