Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. typedef struct student{
  5. char nazwisko[20];
  6. char imie[20];
  7. int indeks;
  8. float ocena;
  9. struct student* next;
  10. }student;
  11.  
  12. void dodajUcznia(student** student1){
  13. system("cls");
  14. student* nowa= (student*)malloc(sizeof(student));
  15. printf("Podaj Nazwisko:");
  16. scanf("%s",&nowa->nazwisko);
  17.  
  18. printf("\nPodaj Imie:");
  19. scanf("%s",&nowa->imie);
  20.  
  21. printf("\nPodaj Numer Indeksu:");
  22. scanf("%d",&nowa->indeks);
  23.  
  24. nowa->ocena=0;
  25.  
  26. system("cls");
  27. dodaj(student1,nowa);
  28. }
  29.  
  30. void dodaj(student** student1, student* nowa){
  31. while (*student1 != NULL) student1 = &((*student1)->next);
  32. *student1 = nowa;
  33. nowa->next = NULL;
  34. }
  35.  
  36. void egzamin(){
  37. }
  38. void usun(student** student1, int ID)
  39. {
  40. student* poprzedni = NULL;
  41. student* wsk = *student1;
  42. int i;
  43. for(i = 1; i < ID; i++)
  44. {
  45. poprzedni=wsk;
  46. wsk=wsk->next;
  47.  
  48. }
  49. if(poprzedni==NULL)
  50. {
  51. (*student1)=(*student1)->next;
  52. free(wsk);
  53. }
  54. else
  55. {
  56. poprzedni->next=wsk->next;
  57. free(wsk);
  58. }
  59. }
  60. void rezygnacja(student** student1){
  61. int ID;
  62. printf("Podaj numer osoby na liscie: " );
  63. scanf("%d", &ID);
  64.  
  65. if((ID > dlugosc_listy(*student1)) || (ID < 1))
  66. {
  67. printf("Nie ma takiego numeru");
  68.  
  69. }
  70. else
  71. {
  72. usun(student1,ID);
  73. }
  74. }
  75.  
  76.  
  77. void lista_studentow(student* student1){
  78.  
  79. student* wsk = student1;
  80.  
  81. if(student1 == NULL)
  82. printf("Brak studentow");
  83. /*else
  84. printf("Lista zawiera %d elementow: \n", dlugosc_listy(lista) );*/
  85. int i = 1;
  86. system("CLS");
  87. while( wsk != NULL)
  88. {
  89. printf("Numer na liscie: %d \nImie: %s \nNazwisko: %s \nNumer albumu: %d\n", i, wsk->imie, wsk->nazwisko, wsk->indeks);
  90. wsk=wsk->next;
  91. i++;
  92. }
  93. getch();
  94. system("CLS");
  95.  
  96. }
  97.  
  98. void przeliczstudentow(){
  99. }
  100.  
  101. int main(){
  102.  
  103. student* student1 = NULL;
  104.  
  105.  
  106. int stop;
  107.  
  108. while(stop!=9){
  109. printf("1. - Dodaj studenta");
  110. printf("\n2. - Rozpocznij egzamin");
  111. printf("\n3. - Rezygnacja studenta");
  112. printf("\n4. - Wyswietl liste studentow");
  113. printf("\n5. - Przelicz studentow");
  114. printf("\n6. - Srednia ocen egzaminu");
  115. printf("\n9. - Zakoncz program");
  116. printf("\nWybieram:");
  117. scanf("%d",&stop);
  118.  
  119. switch(stop){
  120. //Dodaj studenta
  121. case 1:
  122. dodajUcznia(&student1);
  123. break;
  124. //Rozpocznij egzamin
  125. //case 2:
  126. //egzamin();
  127. //Rezygnacja studenta
  128. //case 3:
  129. //rezygnacja();
  130. //Wyswietl liczbe studentow
  131. case 4:
  132. system("CLS");
  133. lista_studentow(student1);
  134. break;
  135. //Przelicz studentow
  136. //case 5:
  137. //przelicz_studtentow();
  138. //case 6:
  139. //srednia_ocen_egzaminu();
  140. }
  141. }
  142. system("cls");
  143. printf("Dziekuje za skorzystanie z programu, zegnam");
  144. getch();
  145. return 0;
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement