Untitled
unknown
plain_text
10 days ago
926 B
2
Indexable
Never
#include <stdio.h> typedef char Item; void STACKinit(int MaxN); int STACKempty(); void STACKpush(Item item); Item STACKpop(); Item *s; int N; int main(){ int celeCislo, zvysokPoDeleni; printf("Zadaj prirodzene cislo v dekadickom tvare: "); scanf("%d", &celeCislo); STACKinit(10); while(celeCislo != 0) { zvysokPoDeleni = celeCislo % 16; celeCislo /= 16; if(zvysokPoDeleni >= 10) { STACKpush(zvysokPoDeleni-10+'A'); }else{ STACKpush(zvysokPoDeleni+'0'); } while(!STACKempty()) { printf("%c", STACKpop()); } } } void STACKinit(int MaxN) { if(!(s = malloc(MaxN * sizeof(Item)))) { printf("Alokovanie pamate zlyhalo."); } N = 0; } int STACKempty() { return N == 0; } void STACKpush(Item item) { s[N++] = item; } Item STACKpop() { return s[--N]; }
Leave a Comment