lundi 20 avril 2020

Stacking Random Numbers

I wanted to stack random numbers and printout the stack. I tried to write the code but I cant find where the problem is coming from Please tell me what I did wrong, thank you a lot


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define MAX_STACK_SIZE 100

int main()
{
    typedef struct {
        int key;
    } element;

    int stack[MAX_STACK_SIZE];
    int top = -1;

    srand((unsigned int)time(NULL));
    int i;

    void push(element, int i);
    {
        if (top >= MAX_STACK_SIZE)
        return;
        for (i = 0; i <= 10; i++)
        {
            i = rand() % 10;
            stack[top++] = i;
        }
    }
    for (i=0; i<=10; i++)
        printf("%d", stack[i]);
        return 0;
}



Aucun commentaire:

Enregistrer un commentaire