Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- #define VELIKOST 8000000
- // const int VELIKOST 100000;
- int main(int argc, char** argv) {
- static char* pole[VELIKOST]; // static umožní větší velikost, je uložený v paměti globálních proměnných
- FILE *seznam= fopen("CZ.txt","r");
- srand(time(NULL));
- char buffer[256];
- int i = 0;
- while(fscanf(seznam,"%255s", buffer)!=EOF && i < VELIKOST) {
- int delka = strlen(buffer);
- if(delka > 1) {
- char* novy = malloc(delka+1);
- strcpy(novy, buffer);
- pole[i++] = novy;
- }
- if ( (i & (4*65536-1)) == 0)
- printf("Precten %d. radek\n", i);
- }
- /* int N = i;
- for(i = 0; i < N; i++)
- puts(pole[i]);
- */
- int nahodne;
- int j;
- char *pozice;
- int delka;
- char *tajenka = "oka";
- char *slova[strlen(tajenka)];
- //int pomocna=0;
- int max_delka=0;
- printf("\n");
- printf("TAJENKA JE :\n\n");
- for(j=0;j<strlen(tajenka);j++) //projit slova
- {
- do{
- nahodne = rand() % 7000000;
- pozice = strchr( pole[nahodne], tajenka[j]); //pokud nenajde pozici=null
- //pomocna=pomocna+1;
- }while(pozice == NULL);
- slova[j]=pole[nahodne];
- delka = pozice -pole[nahodne];
- //delka = strlen(pozice);
- //printf("%d\n",delka); //delka o kolik se má posunout
- if(delka>max_delka)
- {
- max_delka=delka;
- }
- }
- for(int k=0;k<strlen(tajenka);k++)
- {
- pozice = strchr( slova[k], tajenka[k]);
- delka = pozice -slova[k];
- for(int m=0;m<max_delka-delka;m++)
- {
- printf(" ");
- }
- printf("%s\n",slova[k]);
- }
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement