Advertisement
Coriic

Untitled

Jan 16th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. struct sedzia{
  6. char *nazwisko;
  7. int index;
  8. };
  9.  
  10. struct wezel{
  11. struct sedzia *wsk;
  12. struct wezel *next;
  13. };
  14.  
  15. void dodaj (struct wezel **poczatek){
  16. struct wezel *tmp;
  17. char bufor[20];
  18. int dlugosc;
  19. tmp=(struct wezel*)malloc(sizeof(struct wezel));
  20. tmp->wsk=(struct sedzia*)malloc(sizeof(struct sedzia));
  21. getchar();
  22. printf("Podaj nazwisko sedziego: ");
  23. fgets(bufor, 20, stdin);
  24. dlugosc=strlen(bufor)+1;
  25. tmp->wsk->nazwisko=(char *)malloc(sizeof(char)*dlugosc);
  26. strcpy(tmp->wsk->nazwisko, bufor);
  27. printf("Podaj identyfikator sedziego: ");
  28. scanf("%d", &(tmp->wsk->index));
  29. tmp->next=*poczatek;
  30. *poczatek=tmp;
  31. }
  32.  
  33. void wyswietl (struct wezel *poczatek){
  34. struct wezel *tmp;
  35. tmp=poczatek;
  36. while (tmp != NULL){
  37. printf("Nazwisko: %s", tmp->wsk->nazwisko);
  38. printf("Identyfikator: %d\n", tmp->wsk->index);
  39. tmp=tmp->next;
  40. }
  41. }
  42.  
  43. void losuj (struct wezel *poczatek){
  44.  
  45.  
  46.  
  47.  
  48. }
  49.  
  50. int main(void){
  51. struct wezel *poczatek;
  52. int wybor;
  53. poczatek=NULL;
  54. while (wybor != 0){
  55. printf("1) Dodaj sedziego\n");
  56. printf("2) Wyswietl liste\n");
  57. printf("3) Losuj\n");
  58. printf("0) Wyjdz\n");
  59. scanf("%d", &wybor);
  60. if (wybor==1){
  61. dodaj(&poczatek);
  62. }
  63. if (wybor==2){
  64. wyswietl(poczatek);
  65. }
  66. if (wybor==0){
  67. break;
  68. }
  69. if (wybor==0){
  70. losuj(poczatek);
  71. }
  72. wybor=-1;
  73. }
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement