Új hozzászólás Aktív témák

  • babyanigirl

    csendes tag

    #include <stdio.h>
    #pragma hdrstop

    //---------------------------------------------------------------------------

    #pragma argsused
    int main( int argc, char* argv[] )
    {
    int i;
    FILE* f;
    FILE *fp;
    int count[256];

    for(i=0; i<256; i++)
    {
    count[i] = 0;
    }

    f = fopen("input.txt", "rt");

    while(1)
    {
    int c = fgetc(f);
    if( c==EOF )
    break;
    if( c<0 || c>255 ) {
    printf("hiba: nem vart betu");
    return 3;
    }

    count[c] += 1;
    }

    fclose(f);

    printf("gyakorisagok:\n");
    for(i=0; i<256; i++)
    {
    if( count[i] < 1 )
    continue;

    printf("'%c': %d-szer\n", i, count[i]);
    fp=fopen("output.txt", "a+");
    fprintf(fp,"Gyakorisága az");
    fprintf(fp,"%c betunek %d\n", i, count[i]);
    fclose(fp);
    }
    system("pause");
    return 0;
    }

    Mit gondoltok ez így jó?
    Nem lehetne vhogy egyszerűbben megcsinálni?
    BabyAniGirl

Új hozzászólás Aktív témák