Compare commits
No commits in common. "5dfa85ffa5f0bb01c5cca706557df5d05cbf0d2e" and "8a31953c274a21c9ec36e7eba1269475c66414f9" have entirely different histories.
5dfa85ffa5
...
8a31953c27
124
noteverw.c
124
noteverw.c
@ -1,124 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
typedef struct schueler {
|
|
||||||
char name[50];
|
|
||||||
char vorname[50];
|
|
||||||
int note;
|
|
||||||
struct schueler *next
|
|
||||||
}Schueler;
|
|
||||||
|
|
||||||
|
|
||||||
void einfuegen (Schueler *head, char *name, char *vorname, int note ){
|
|
||||||
|
|
||||||
Schueler* current = head;
|
|
||||||
|
|
||||||
Schueler *neu = malloc(sizeof(Schueler));
|
|
||||||
|
|
||||||
|
|
||||||
while(current->next != NULL) {
|
|
||||||
current = current->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(neu->name, name);
|
|
||||||
strcpy(neu->vorname, vorname);
|
|
||||||
neu->note = note;
|
|
||||||
neu->next = NULL;
|
|
||||||
|
|
||||||
current -> next = neu;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void printList(Schueler *head){
|
|
||||||
Schueler* current = head -> next;
|
|
||||||
int counter = 1;
|
|
||||||
|
|
||||||
while(current->next != NULL) {
|
|
||||||
printf("%d. %s \t\t%s \t\t%d \n",counter, current -> name, current -> vorname, current -> note);
|
|
||||||
counter++;
|
|
||||||
current = current->next;
|
|
||||||
}
|
|
||||||
printf("%d. %s \t\t%s \t\t%d \n",counter, current -> name,current -> vorname, current -> note);
|
|
||||||
}
|
|
||||||
|
|
||||||
void durch(int *spiegel) {
|
|
||||||
|
|
||||||
for (int i = 1; i <= 6 ; ++i) {
|
|
||||||
printf("Note %d:", i);
|
|
||||||
|
|
||||||
|
|
||||||
for (int j = 0; j < spiegel[i-1]; ++j) {
|
|
||||||
printf("*");
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int main (){
|
|
||||||
Schueler anker;
|
|
||||||
char name[50], vorname[50], note_eingabe[10];
|
|
||||||
int note, counter = 1, temp = 0, spiegel[6] = {};
|
|
||||||
double durchschnitt = 0;
|
|
||||||
|
|
||||||
anker.next= NULL;
|
|
||||||
|
|
||||||
do {
|
|
||||||
printf("----Eingabe des %d.Schuelers----\n", counter);
|
|
||||||
printf("Name:");
|
|
||||||
fgets(name, sizeof(name), stdin);
|
|
||||||
|
|
||||||
if(strcmp(name, "\n") == 0){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
name[strcspn(name, "\n")] = '\0';
|
|
||||||
|
|
||||||
printf("Vorname:");
|
|
||||||
fgets(vorname, sizeof(vorname), stdin);
|
|
||||||
vorname[strcspn(vorname, "\n")] = '\0';
|
|
||||||
|
|
||||||
|
|
||||||
printf("Note:");
|
|
||||||
fgets(note_eingabe, sizeof(note_eingabe), stdin);
|
|
||||||
note_eingabe[strcspn(note_eingabe, "\n")] = '\0';
|
|
||||||
note = atoi(note_eingabe);
|
|
||||||
|
|
||||||
switch (note) {
|
|
||||||
case 1:
|
|
||||||
spiegel[0] += 1;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
spiegel[1] +=1;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
spiegel[2] += 1;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
spiegel[3] += 1;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
spiegel[4] += 1;
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
spiegel[5] += 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
einfuegen(&anker, name, vorname, note);
|
|
||||||
|
|
||||||
temp += note;
|
|
||||||
|
|
||||||
counter++;
|
|
||||||
}while(1);
|
|
||||||
|
|
||||||
printf("Name \tVorname \tNote\n");
|
|
||||||
printf("---------------------------------------------------\n");
|
|
||||||
printList(&anker);
|
|
||||||
printf("....Durchschnittsnote: %.2f\n", (double)temp / (counter - 1));
|
|
||||||
printf("...Notenspiegel\n");
|
|
||||||
durch((int *)spiegel);
|
|
||||||
}
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user