示例#1
0
文件: main.cpp 项目: DariaDar/Reposit
void reaction(stack_t * st, char * str)
{
    int num;
    sscanf(str, "pop %i", &num);
    if(num > stack_getCount(st))
    {
        printf("Number is bigger than count elements in stack.");
        return;
    }
    for(int i = 0; i < num - 1; i++)
        stack_pop(st);
}
示例#2
0
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;
}
示例#3
0
文件: main.cpp 项目: DariaDar/Reposit
int check(stack_t * st, char * str)
{
    if((int)stack_getCount(st) > 10)
        return 1;
    return 0;
}
示例#4
0
int compare (stack_t *a) {
    return stack_getCount(a) > 10;
}