Advertisement
Coriic

Untitled

Jan 16th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 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. printf("Podaj nazwisko sedziego: ");
  21. fgets(bufor, 20, stdin);
  22. dlugosc=strlen(bufor);
  23. tmp->wsk->nazwisko=(char *)malloc(sizeof(char)*(dlugosc+1));
  24. strcpy(tmp->wsk->nazwisko, bufor);
  25. printf("Podaj identyfikator sedziego: ");
  26. scanf("%d", &(tmp->wsk->index));
  27. tmp->next=*poczatek;
  28. *poczatek=tmp;
  29. }
  30.  
  31. void wyswietl (struct wezel *poczatek){
  32. struct wezel *tmp;
  33. tmp=poczatek;
  34. while (tmp != NULL){
  35. printf("Nazwisko: %s\n", tmp->wsk->nazwisko);
  36. printf("Identyfikator: %d\n", tmp->wsk->index);
  37. tmp=tmp->next;
  38. }
  39. }
  40.  
  41. int main(void){
  42. struct wezel *poczatek;
  43. int wybor;
  44. poczatek=NULL;
  45. dodaj(&poczatek);
  46. wyswietl(poczatek);
  47. /*while (wybor != 0){
  48. printf("1) Dodaj sedziego\n");
  49. printf("2) Wyswietl liste sedziow\n");
  50. printf("3) Losuj\n");
  51. scanf("%d", &wybor);
  52. if (wybor==1){
  53. dodaj(&poczatek);
  54. }
  55. if (wybor==2){
  56. wyswietl(poczatek);
  57. }
  58. wybor=-1;
  59. }*/
  60.  
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement