/**(c) 5 Michał (Foxbond) Chraniuk */
#include <stdio.h>
void cls(void) { system("cls"); }
typedef struct zgloszenie{
char zgloszenie[40];
char zglaszajacy[40];
struct zgloszenie *next;
}zgloszenie;
int main (){
char opt;
zgloszenie *q = NULL;
do {
cls();
printf("Witaj w systemie zgloszen\n\nWybierz zadana operacje:\n1. Dodaj zgloszenie\n2. Pobierz zgloszenie\n3. Wyswietl zgloszenia\n0. Wyjscie\n");
opt = getch();
cls();
if (opt == '1'){
zgloszenie *buf = (zgloszenie*)malloc(sizeof(zgloszenie));
printf("1. Dodawanie zgloszenia\nZgloszenie: ");
fflush(stdin);
scanf("%s", &buf->zgloszenie);
printf("\nZglaszajacy: ");
fflush(stdin);
scanf("%s", &buf->zglaszajacy);
buf->next=NULL;
char temp;
do {
printf("\nStatus VIP? (y/n): ");
temp = getch();
if (temp == 'Y') temp = 'y';
if (temp == 'N') temp = 'n';
} while (temp != 'y' && temp != 'n');
if (q == NULL){
q = buf;
}else{
if (temp == 'y'){
buf->next = q;
q=buf;
}else {
zgloszenie *pointer = q;
for (;;){
if (pointer->next != NULL){
pointer = pointer->next;
}else{
pointer->next = buf;
break;
}
}
}
}
printf("\nDodano do kolejki!");
getch();
}else if (opt == '2'){
if (q == NULL){
printf("Kolejka jest pusta!");
}else{
printf("Pobrane zgloszenie:\n%s\nZglaszajacy: %s\n", q->zgloszenie, q->zglaszajacy);
q = q->next;
}
getch();
}else if (opt == '3'){
if (q == NULL){
printf("Kolejka jest pusta!");
}else{
printf("Zgloszenie\t|\tZglaszajacy\n");
zgloszenie *pointer = q;
for (;;){
printf("%s\t\t|\t\t%s\n", pointer->zgloszenie, pointer->zglaszajacy);
if (pointer->next != NULL){
pointer = pointer->next;
}else{
break;
}
}
}
getch();
}
}while(opt != '0');
return 0;
}
> Back