Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct list {
- char cod[20];
- float pret;
- enum{telefon, unitate, tableta}tip;
- struct list *urm;
- }depozit;
- int main()
- {
- depozit *head = NULL, *p = NULL;
- int opt, ok, i;
- do {
- printf("1. Introducere echipament nou\n");
- printf("2. Afisare lista\n");
- printf("3. Schimbare paritate bit\n");
- printf("4. Iesire\n");
- printf("4. Optiunea aleasa: ");
- scanf("%d", &opt);
- switch (opt) {
- case 1:
- p = head;
- head = (depozit *)malloc(sizeof(depozit));
- head->urm = NULL;
- do{
- ok = 0;
- printf("Cod: "); scanf("%s", head-> cod);
- if (head->cod[0] >= '0' && head->cod[0] <= '9' && head->cod[1] >= 'a' && head->cod[1] <= 'z' && head->cod[2] == '-') {
- for (i = 3; head->cod[i]; i++)
- if (head->cod[i] < '0' || head->cod[i] > '9') break;
- if (head->cod[i] == 0)
- ok = 1;
- }
- } while (ok == 0);
- printf("Pret: "); scanf("%f", &head->pret);
- printf("Tip: "); scanf("%d", &head->tip);
- head->urm = p;
- break;
- case 2:
- p = head;
- while (p) {
- printf("Cod produs %s \n", p->cod);
- printf("Pret de vanzare %f \n", p->pret * 1.15);
- printf("Tip %d \n", p->tip);
- p = p->urm;
- }
- break;
- case 4: return 0;
- }
- } while (1);
- }
Advertisement
Add Comment
Please, Sign In to add comment