Untitled
unknown
plain_text
2 years ago
737 B
20
Indexable
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int head =0;
int a[5] = {0,0,0,0,0}; //vektor me 5 elemente
int main(int argc, char *argv[]) {
push(10,head);
pop();
int i=0;
for(i=0; i<5 ; i++)
{
printf("%d ",a[i]);
}
return 0;
}
void push(int elementi, int head)
{
if(head = 5)
{
printf("Staku eshte plot dhe nuk mund ti shtohet nje element i ri")
}
else {
a[head]=elementi; //a[1]=5;
head = head + 1 ; //head=2;
}
}
void pop() {
if(head == -1)
{
printf("Stacku eshte bosh, nuk mund te hiqet element");
}
else
{
head = head - 1;
a[head]=0;
}
}
Editor is loading...