Programme wurden hinzugefügt

This commit is contained in:
Leaced 2017-04-02 17:06:39 +02:00
parent 4dc5ad0c5f
commit e64095ceee
4 changed files with 342 additions and 0 deletions

92
Mathe/Classes.cpp Normal file
View file

@ -0,0 +1,92 @@
#include<iostream>
#include<string>
#include<sstream>
#include<math.h>
class Point
{
public:
double X, Y;
void setX(double x)
{
X = x;
}
void setY(double y)
{
Y = y;
}
Point(double x = 0, double y = 0)
{
X = x;
Y = y;
}
void print()
{
std::cout << "(" << X << "," << Y << ")";
}
};
class Line
{
public:
Point P, Q;
double b, m;
void setPoint(bool p, Point point)
{
if(p==0)
{
Q.setX(point.X);
Q.setY(point.Y);
}
else
{
P.setX(point.X);
P.setY(point.Y);
}
}
void distance()
{
std::cout << sqrt((P.X-Q.X)*(P.X-Q.X)+(P.Y-Q.Y)*(P.Y-Q.Y));
}
void gradient()
{
m = (P.Y-Q.Y)/(P.X-Q.X);
}
void nullPointX()
{
b = (-P.X)*(P.Y-Q.Y)/(P.X-Q.X)+(P.Y);
std::cout << b;
}
void nullPointY()
{
std::cout << (P.X)*(P.Y-Q.Y)/(P.X-Q.X)/((P.Y-Q.Y)/(P.X-Q.X));
}
void print()
{
gradient();
std::cout << m <<"*x + ";
nullPointX();
}
};
int main()
{
Point P(3,5), Q(5,3);
Line g;
g.setPoint(0, Q);
g.setPoint(1, P);
g.print();
getchar();
}

92
Schleifen.cpp Normal file
View file

@ -0,0 +1,92 @@
#include<iostream>
#include<string>
#include<sstream>
int main()
{
long long depth;
std::string input;
std::cout << "Geben sie die Tiefe ein: ";
getline(std::cin, input);
std::stringstream(input) >> depth;
if(depth<2)
{
std::cout << "ERROR: Zahl muss größer als 1 sein.";
getchar();
return(1);
}
for(long long idx = 0; idx<depth*depth; idx++)
{
if(idx%depth==0) std::cout << "\n";
std::cout << "*";
}
std::cout << "\n";
for(long long idx = 0; idx<depth; idx++)
{
std::cout << "\n";
for(long long idx2 = 0; idx2<idx; idx2++)
{
std::cout << " ";
}
for(long long idx2 = 0; idx2<depth*2-1-2*idx; idx2++)
{
std::cout << "*";
}
}
std::cout << "\n\n";
for(long long idx = 0; idx<depth-1; idx++)
{
for(long long idx2 = 0; idx2<depth-idx-1; idx2++)
{
std::cout << " ";
}
std::cout << "*";
for(long long idx2 = 0; idx2<2*idx-1; idx2++)
{
std::cout << " ";
}
if(idx>0) std::cout << "*";
std::cout << "\n";
}
for(long long idx = 0; idx<2*depth-1; idx++)
{
std::cout << "*";
}
for(long long idx = 0; idx<depth-2; idx++)
{
std::cout << "\n*";
for(long long idx2 = 0; idx2<2*depth-3; idx2++)
{
std::cout << " ";
}
std::cout << "*";
}
std::cout << "\n";
for(long long idx = 0; idx<2*depth-1; idx++)
{
std::cout << "*";
}
std::cout << "\n\n\n\nProgrammende!";
getchar();
return(0);
}

65
Tage seit.cpp Normal file
View file

@ -0,0 +1,65 @@
#include<iostream>
#include<string>
#include<sstream>
int main()
{
std::string stringInput;
unsigned long long day, month, year;
short daysInMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30};
std::cout << "Gib den Tag des Monats ein: ";
getline(std::cin, stringInput);
std::stringstream(stringInput) >> day;
if(day>31 || day<1)
{
std::cout << "ERROR: Der eingegebene Tag existiert nicht.";
return(1);
}
std::cout << "Gib den Monat ein: ";
getline(std::cin, stringInput);
std::stringstream(stringInput) >> month;
if(month>12 || month<1)
{
std::cout << "ERROR: Der eingegebene Monat existiert nicht.";
return(1);
}
if(day>daysInMonth[month] && month!=2 || month==2 && day>29)
{
std::cout << "ERROR: Es wurden zuviele Tage f\x81r diesen Monat eingegeben.";
return(1);
}
if(day==29 && month==2) daysInMonth[1]++;
std::cout << "Gib das Jahr ein: ";
getline(std::cin, stringInput);
std::stringstream(stringInput) >> year;
if(year<0)
{
std::cout << "ERROR: Der 1. Januar 0 liegt in der Zukunft.";
return(1);
}
if(day==29 && month == 2 && (year%4!=0 || year%100==0 && year%400!=0))
{
std::cout << "ERROR: Die bereits erfolgten Eingaben benötigen ein Schaltjahr.";
return(1);
}
std::cout << "\nVom 1. Januar 0 bis zum " << day << "." << month << "." << year;
for(short idx = 0; idx<month-1; idx++)
{
day += daysInMonth[idx];
}
std::cout << " sind " << year*365+year/4-year/100+year/400+day-1 <<" Tage vergangen.";
getchar();
return(0);
}

93
weekday.cpp Normal file
View file

@ -0,0 +1,93 @@
#include<iostream>
#include<string>
#include<sstream>
#include<conio.h>
int main()
{
std::string input;
short day, month, daysInMonth[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, weekday, year;
std::cout << "Gib das Tagesdatum ein: ";
getline(std::cin, input);
std::stringstream(input) >> day;
if(day==0 || day>31)
{
std::cout << "\nERROR: Das eingegebene Tagesdatum existiert nicht.";
getch();
return(1);
}
std::cout << "Gib den Monat ein: ";
getline(std::cin, input);
std::stringstream(input) >> month;
if(daysInMonth[month-1]<day)
{
std::cout << "\nERROR: Der eingegebene Monat hat keine " << day << " Tage.";
getch();
return(1);
}
if(month>12 || month==0)
{
std::cout << "\nERROR: Der eingegebene Tag existiert nicht.";
getch();
return(1);
}
std::cout << "Gib das jahr ein: ";
getline(std::cin, input);
std::stringstream(input) >> year;
if(year>10000 || year<0)
{
std::cout << "\nERROR: Im eingegeben Jahr lässt sich der Wochentag nicht ermitteln.";
getch();
return(1);
}
if(day==29 && month==2 && (year%4!=0 || year%100==0))
{
std::cout << "\nERROR: Die Eingaben ben\x94tigen ein Schaltjahr.";
getch();
return(1);
}
std::cout << "\nDer " << day << "." << month << "." << year << " war ein ";
if(month==1 || month==2) year -=1;
switch (month)
{
case 1: month = 0; break;
case 8: month = 1; break;
case 2:
case 6: month = 3; break;
case 9:
case 12: month = 4; break;
case 4:
case 7: month = 5; break;
case 10: month = 6; break;
default: month = 2; break;
}
weekday = (day+month+(year%100)+(year%100/4)+year/400-2*(year/100))%7;
while(weekday<0) weekday += 7;
switch(weekday)
{
case 0: std::cout << "Sonntag"; break;
case 1: std::cout << "Montag"; break;
case 2: std::cout << "Dienstag"; break;
case 3: std::cout << "Mittwoch"; break;
case 4: std::cout << "Donnerstag"; break;
case 5: std::cout << "Freitag"; break;
case 6: std::cout << "Samstag"; break;
}
getch();
return(0);
}