コード例 #1
0
ファイル: main.c プロジェクト: AndreyKrysyuk/KP52OP
int main(void) {
    progQueue_t queue = progQueue_new();

    const char * dllName = userChoice();
    dynamic_t * dll = dynamic_init(dllName);
    if (NULL == dll) {
        printf("Can't load dynamic!\n");
        return 1;
    }
    if (NULL == dll->check) {
        printf("Can't get compare function!\n");
        return 1;
    }
    if (NULL == dll->react) {
        printf("Can't get reaction function!\n");
        return 1;
    }
    printf("Dynamic loaded!");

    srand(time(NULL));

    for(int i = 0; i < 8; i++){
         progQueue_enqueue(queue, rand() % 25);
    }
    puts("");
    progQueue_print(queue);
    if(dll->check(queue) == 1)
        dll->react();
    else
        printf("OK\n");

    progQueue_remove(queue);
    dynamic_clean(dll);
    return 0;
}
コード例 #2
0
int main(void) {
    const int MAX_QUEUE_SIZE = 7;
    Queue_t queue = Queue_new();
    const char * dllName = userChoice();
    dynamic_t * dll = dynamic_init(dllName);
    if (NULL == dll) {
        printf("Can't load dynamic!\n");
        return 1;
    }
    if (NULL == dll->check) {
        printf("Can't get compare function!\n");
        return 1;
    }
    if (NULL == dll->react) {
        printf("Can't get reaction function!\n");
        return 1;
    }
    puts("Dynamic loaded!");
    srand(time(NULL));
    for (int i = 0; i < MAX_QUEUE_SIZE; i++) {
        int prec =  !(rand() % 3) ? 1 + rand() % 15 : 0;
        printf("%dth day's precipitation: %d\n", i, prec);
        Queue_enqueue(queue, prec);
    }
    if(dll->check(queue))
        dll->react();
    Queue_delete(queue);
    return 0;
}
コード例 #3
0
ファイル: main.c プロジェクト: antonmazun/gogog
int main(){

const char * dllName = userChoice();
    dynamic_t * dll = dynamic_init(dllName);
    if (NULL == dll) {
        printf("Can't load dynamic!\n");
        return 1;
    }
    if (NULL == dll->cmp) {
        printf("Can't get compare function!\n");
        return 1;
    }
    if (NULL == dll->react) {
        printf("Can't get reaction function!\n");
        return 1;
    }
     printf("Dynamic loaded!\n");
     fflush(stdin);

    char str[100];
    gets(str);
    word_t * words = senToWords(str);
    puts("Done");
   //printf("Dynamic loaded!\n");
    /*for (int i = 0; words[i] != NULL; i++)
        puts(words[i]);*/
    if (words != NULL)
    if (dll->cmp(words))
        dll->react(words);

    return 0;
}
コード例 #4
0
ファイル: main.c プロジェクト: kate-levoshko/Kate-repos
int main(){
    queue_t * q1 = queue_createQueue();
    const char * dllName = userChoice();
    dynamic_t * dll = dynamic_init(dllName);
    int sum = 0;
    if (NULL == dll) {
        printf("Can't load dynamic!\n");
        return 1;
    }
    if (NULL == dll->cmp) {
        printf("Can't get compare function!\n");
        return 1;
    }
    if (NULL == dll->react) {
        printf("Can't get reaction function!\n");
        return 1;
    }
    srand(time(NULL));
    printf("Dynamic loaded!\n");
    while (queue_getCount(q1) < MAX_QUEUE_SIZE){
        queue_enqueue(q1, rand() % 100);
        printQueue(q1, sum);
        if(dll->cmp(q1)) {
            sum = dll->react(q1);
        }
    }
    queue_free(q1);

    return 0;
}
コード例 #5
0
ファイル: main.c プロジェクト: OlgaYashan/-little-princess
int main(void) {
    const int MAX_STACK_SIZE = 10;
    stack_t * stack1 = stack_new();
    const char * dllName = userChoice();
    dynamic_t * dll = dynamic_init(dllName);
    if (NULL == dll) {
        printf("Can't load dynamic!\n");
        return 1;
    }
    if (NULL == dll->check) {
        printf("Can't get compare function!\n");
        return 1;
    }
    if (NULL == dll->react) {
        printf("Can't get reaction function!\n");
        return 1;
    }
    printf("Dynamic loaded!");
    Sleep(500);
    srand(time(NULL));
    while (stack_getCount(stack1) < MAX_STACK_SIZE) {
        stack_push(stack1, rand() % 100 - 50);
        printStacks(stack1);
        }
        if(dll->check(stack1)==1){
            dll->react(stack1);
        }
        else{
            return 0;
        }

        printStacks(stack1);
        Sleep(500);
        stack_free(stack1);
        return 0;
}