Alx09

Untitled

Mar 22nd, 2021
828
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. typedef struct list {
  3.     char cod[20];
  4.     double pret;
  5.     enum{telefon, unitate, tableta}tip;
  6.     struct list *urm;
  7. }depozit;
  8.  
  9.  
  10.  
  11.  
  12. int main()
  13. {
  14.     depozit *head = NULL;
  15.     char cod[20];
  16.     int opt, ok, i;
  17.     do {
  18.         printf("1. Introducere echipament nou\n");
  19.         printf("2. Afisare lista\n");
  20.         printf("3. Schimbare paritate bit\n");
  21.         printf("4. Iesire\n");
  22.         scanf("%d", &opt);
  23.         switch (opt) {
  24.         case 1:
  25.             do{
  26.                 ok = 0;
  27.                 printf("Cod: "); scanf("%s", cod);
  28.                 if (cod[0] >= '0' && cod[0] <= '9' && cod[1] >= 'a' && cod[1] <= 'z' && cod[2] == '-') {
  29.                     for (i = 3; cod[i] != 0; i++)if (cod[i] < '0' || cod[i] > '0') break;
  30.                     if (cod[i] == 0) ok = 0;
  31.                 }
  32.  
  33.             } while (ok == 0);
  34.             break;
  35.         case 4: return 0;
  36.         }
  37.     } while (1);
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment