Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<stdlib.h>
- typedef struct student{
- char nazwisko[20];
- char imie[20];
- int indeks;
- float ocena;
- struct student* next;
- }student;
- int dlugosc_listy(student* student1)
- {
- int d = 0;
- student* wsk = student1;
- while(wsk != NULL)
- {
- d++;
- wsk = wsk->next;
- }
- return d;
- }
- void dodaj(student** student1, student* nowa){
- while (*student1 != NULL) student1 = &((*student1)->next);
- *student1 = nowa;
- nowa->next = NULL;
- }
- void dodajUcznia(student** student1){
- system("cls");
- student* nowa= (student*)malloc(sizeof(student));
- printf("Podaj Nazwisko:");
- scanf("%s",&nowa->nazwisko);
- printf("\nPodaj Imie:");
- scanf("%s",&nowa->imie);
- printf("\nPodaj Numer Indeksu:");
- scanf("%d",&nowa->indeks);
- nowa->ocena=0;
- system("cls");
- dodaj(student1,nowa);
- }
- void egzamin(student* student1){
- student* wsk = student1;
- if(student1 == NULL)
- printf("Brak studentow");
- int i = 1;
- system("CLS");
- while( wsk->ocena = 0)
- {
- printf("Numer na liscie: %d \nImie: %s \nNazwisko: %s \nNumer albumu: %d\n", i, wsk->imie, wsk->nazwisko, wsk->indeks);
- printf("\nPodaj ocene ucznia: ");
- scanf("%d", wsk->ocena);
- wsk=wsk->next;
- i++;
- }
- getch();
- system("CLS");
- }
- void usun(student** student1, int ID)
- {
- student* poprzedni = NULL;
- student* wsk = *student1;
- int i;
- for(i = 1; i < ID; i++)
- {
- poprzedni=wsk;
- wsk=wsk->next;
- }
- if(poprzedni==NULL)
- {
- (*student1)=(*student1)->next;
- free(wsk);
- }
- else
- {
- poprzedni->next=wsk->next;
- free(wsk);
- }
- }
- void rezygnacja(student** student1){
- int ID;
- printf("Podaj numer osoby na liscie: " );
- scanf("%d", &ID);
- if((ID > dlugosc_listy(*student1)) || (ID < 1))
- {
- printf("Nie ma takiego numeru");
- }
- else
- {
- usun(student1,ID);
- }
- }
- void lista_studentow(student* student1){
- student* wsk = student1;
- if(student1 == NULL)
- printf("Brak studentow");
- int i = 1;
- system("CLS");
- while( wsk != NULL)
- {
- printf("Numer na liscie: %d \nImie: %s \nNazwisko: %s \nNumer albumu: %d\n", i, wsk->imie, wsk->nazwisko, wsk->indeks);
- wsk=wsk->next;
- i++;
- }
- getch();
- system("CLS");
- }
- void przeliczstudentow(){
- }
- void sredniaocen(){
- }
- int main(){
- student* student1 = NULL;
- int stop;
- while(stop!=9){
- printf("1. - Dodaj studenta");
- printf("\n2. - Rozpocznij egzamin");
- printf("\n3. - Rezygnacja studenta");
- printf("\n4. - Wyswietl liste studentow");
- printf("\n5. - Przelicz studentow");
- printf("\n6. - Srednia ocen egzaminu");
- printf("\n9. - Zakoncz program");
- printf("\nWybieram:");
- scanf("%d",&stop);
- switch(stop){
- //Dodaj studenta
- case 1:
- dodajUcznia(&student1);
- break;
- //Rozpocznij egzamin
- case 2:
- system("CLS");
- egzamin(student1);
- break;
- //Rezygnacja studenta
- case 3:
- rezygnacja(&student1);
- break;
- //Wyswietl liczbe studentow
- case 4:
- system("CLS");
- lista_studentow(student1);
- break;
- //Przelicz studentow
- //case 5:
- //przeliczstudtentow();
- //case 6:
- //srednia_ocen_egzaminu();
- }
- }
- system("cls");
- printf("Dziekuje za skorzystanie z programu, zegnam");
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement