inital commit, adding all school projects
This commit is contained in:
58
funktionen/main.cpp
Normal file
58
funktionen/main.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include <iostream>
|
||||
#include <windows.h>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool eingabe(const int a) {
|
||||
if (a < 1000 && a > 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void zaehler(const int a) {
|
||||
if (a < 50 && a > 1) {
|
||||
for (int i = 0; i < a; i++) {
|
||||
cout << i+1 << ", ";
|
||||
}
|
||||
} else {
|
||||
cout << "falsche Zahl";
|
||||
}
|
||||
}
|
||||
|
||||
double fakultaet(const int n) {
|
||||
if (n < 0) return 0; // Fakultät für negative Zahlen nicht definiert
|
||||
double fakultaet = 1;
|
||||
for (double i = 1; i <= n; ++i) {
|
||||
fakultaet *= i;
|
||||
}
|
||||
return fakultaet;
|
||||
}
|
||||
|
||||
int main() {
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
cout << fixed << setprecision(2);
|
||||
|
||||
cout << "1. Eingabe!!!" << endl << "Eine zahl bitte zwischen 1 und 1000: \n";
|
||||
int iEingabe;
|
||||
cin >> iEingabe;
|
||||
|
||||
cout << endl << eingabe(iEingabe);
|
||||
|
||||
|
||||
cout << endl << endl << "eine zahl zwischen 1 und 50: \n";
|
||||
int iZahl;
|
||||
cin >> iZahl;
|
||||
|
||||
zaehler(iZahl);
|
||||
cout << endl;
|
||||
|
||||
cout << endl << endl << "Eine zahl bitte:\n";
|
||||
double iFakultaet;
|
||||
cin >> iFakultaet;
|
||||
|
||||
cout << endl << fakultaet(iFakultaet);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user