Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as C by jstc ( 12 years ago )
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
/* Promene, pole */
int i;
int c = 0;
int ch;
int g = 0;
int b = 0;
int nacteny_znak;
int x = 0;
unsigned int pole_znaku[256];
unsigned int pole_pismen[256];
unsigned int pole_hodnota[256];
/* Cyklus pro vytvoreni pole prvku kde kazdy se bude rovnat 0, a a cislo pole treba a[107]=vyskyt, 107 = ascii kod pro pismeno k */
for (i = 0; i < 256; i++)
pole_znaku[i] = 0;
/* Nacteni souboru, cteni po pismenu a zapisovani pismena do pole znaku */
FILE *input;
if (input = fopen("fred.txt", "rt"))
{
ch = getc(input);
while (ch != EOF)
{
nacteny_znak = ch;
pole_znaku[nacteny_znak]++;
printf("%c\n", ch);
printf("%i\n", nacteny_znak);
printf("------------------------\n");
ch = getc(input);
}
fclose(input);
}
printf("%i\n", pole_znaku[32]);
for (b = 0; b < 20; b++)
{
for (c = 0; c < 255; c++)
{
while (pole_znaku[c] >= pole_znaku[g])
{
g++;
if (g == 256 && pole_znaku[c] != 0)
{
pole_pismen[x] = c;
pole_hodnota[x] = pole_znaku[c];
pole_znaku[c] = 0;
printf("%i\n", pole_znaku[c]);
x++;
}
}
g = 0;
}
}
printf("\n");
printf("%c\n", pole_pismen[0]);
printf("%i\n", pole_hodnota[0]);
printf("\n");
printf("%c\n", pole_pismen[1]);
printf("%i\n", pole_hodnota[1]);
printf("\n");
printf("%c\n", pole_pismen[2]);
printf("%i\n", pole_hodnota[2]);
printf("\n");
printf("%c\n", pole_pismen[3]);
printf("%i\n", pole_hodnota[3]);
printf("\n");
printf("%c\n", pole_pismen[4]);
printf("%i\n", pole_hodnota[4]);
}
Revise this Paste