#include #include typedef struct POL { int data; struct POL *next; } pol; pol *zac=NULL; int pridej(int x) { pol *pom; pom=(pol *)malloc(sizeof(pol)); if (pom==NULL) { printf("\nNedostatek pameti"); return 1; } pom->data=x; pom->next=zac; zac=pom; return 0; } int pocpol() { int n=0; pol *pom; pom=zac; while (pom!=NULL) { n++; pom=pom->next; } return n; } void vypisvse() { pol *pom; printf("\nSeznam: "); pom=zac; while (pom!=NULL) { printf(" %d", pom->data); pom=pom->next; } } int zjistizamen(pol **x) { pol *y; if (*x==NULL) return 0; if ((y=(*x)->next)==NULL) return 0; if ((*x)->datadata) return 0; (*x)->next=y->next; y->next=*x; *x=y; return 1; } void tridsez() { pol **pom; int sw; do { for (sw=0,pom=&zac;*pom!=NULL;pom=&((*pom)->next)) sw=zjistizamen(pom)||sw; // prava strana vyrazu nesmi mit prohozene operandy! } while (sw); } int main() { int i; int err=0; printf("Zadavejte cela cisla. Ukonceni zadanim nuly.\n"); while (err==0) { printf(": "); scanf("%d", &i); if (i!=0) { err=pridej(i); } else err=5; } printf("\nCelkem bylo zadano %d cisel.", pocpol()); vypisvse(); tridsez(); vypisvse(); while(!kbhit()) ; return 0; }