Cod sursa(job #1506332)

Utilizator mitroi_stefan_danielMitroi Stefan-Daniel mitroi_stefan_daniel Data 20 octombrie 2015 14:52:23
Problema Text Scor 50
Compilator c Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){

    int k=-1,s2=0,s1=0,o=0;
    char s[1000],*p,c;
    FILE *f,*g;

    f=fopen("text.in","r");
    g=fopen("text.out","w");

    while(!feof(f)){
        fscanf(f,"%c",&c);
        k++;
        s[k]=c;
    }


    p=strtok(s," -?.,!\n;'");
    while(p!=NULL){
        s1=strlen(p);
        s2+=s1;
        o++;
        printf("%s  %d %d \n",p,s1,s2);
        p=strtok(NULL," -?.,!\n;'");

    }

printf("%d\n",s2);
printf("%d\n",o);
fprintf(g,"%d",s2/o);


    return 0;
}