This commit is contained in:
Daniel Zwanzig 2025-03-31 19:22:03 +02:00 committed by Tamer Öztürk
parent c2772032d7
commit 4c967750a0
7 changed files with 56 additions and 1 deletions

8
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

2
.idea/Informatik2_Pr.iml generated Normal file
View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CIDR" type="CPP_MODULE" version="4" />

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Informatik2_Pr.iml" filepath="$PROJECT_DIR$/.idea/Informatik2_Pr.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

29
quersum.c Normal file
View File

@ -0,0 +1,29 @@
#include <stdio.h>
int quersum(int zahl, int qsumme) {
if (zahl != 0) {
qsumme += zahl % 10;//Nimm die rechteste Zahl als einzelne Zahl und addiert auf qsumme
zahl = zahl / 10;//verschiebt Komma einmal nach links damit nächste Zahl auf qsumme addiert werden kann
quersum(zahl, qsumme);
} else
return qsumme;
}
void reverse(int zahl) {
if (zahl != 0) { //Abbruchbedingung
printf("%d", zahl % 10); //Nimmt die letzte Ziffer und gibt sie aus.
reverse(zahl /10); //Rekursion: Teilt duch 10, damit die vorletzte Ziffer der Ursprungszahl die neue letzt Ziffer wird
}
}
int main(void) {
int eingabe = 0;
int qsumme = 0;
printf("Gib eine Zahl ein:");
scanf("%d", &eingabe);
printf("----Quersumme: %d\n",quersum(eingabe, qsumme)); //da Funktion einen Return Wert hat wird sie hier aufgerufen
printf("----umgedreht: ");
reverse(eingabe);
}

View File

@ -31,5 +31,7 @@ int main(void){
printf("====================================\n\n");
printf("Das Maximum der Zahlen ");
vielmax(100, 24, 5226, 3243, 8238, 23, 22, 1, 0); //100 ist die maximale Anzahl der eingelesenen Zahlen
// vielmax(100, 24, 5226, 3243, 8238, 23, 22, 1, 0); //100 ist die maximale Anzahl der eingelesenen Zahlen
// vielmax(100,3, 6, 0, 10, 12,0);
// vielmax(5, 7, 8, 3, 4, 1, 19, 0);
}

BIN
vielmax.exe Normal file

Binary file not shown.