This commit is contained in:
2025-04-04 11:51:22 +02:00
committed by oeztuerkta87697
parent c2772032d7
commit 4c967750a0
7 changed files with 56 additions and 1 deletions
+8
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
View File
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CIDR" type="CPP_MODULE" version="4" />
+8
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>
Generated
+6
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
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);
}
+3 -1
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
View File
Binary file not shown.