leonardodeku
-
Gesamte Inhalte
6 -
Benutzer seit
-
Letzter Besuch
Inhaltstyp
Profile
Forum
Downloads
Kalender
Blogs
Shop
Beiträge von leonardodeku
-
-
#include <iostream>
using namespace std;
int main()
{int points;
int rows = 9;
int cols = 6;
int Field[rows][cols];int N = 45;
int y;
int x;for (int i = 0; i < rows ; i++){
for(int j = 0 ; j < cols; j++){ Field[j] = 0;
}
}cout << "Wie Viele Punkte wollen Sie: ";
cin >> points; if(points != N){
cout << "X und Y eingeben: " << endl;
for (int i = 1 ; i <= points ; i++){
cout << "Eingabe " << i << " : ";
cin >> x >> y;
while (x > 50 || y > 9)
{
cout << "falsche Eingabe\n";
cout << "Eingabe " << i << " : ";
cin >> x >> y; }
if(x % 10 == 0){
x = x / 10; Field[y][x] = 1;
}
}
cout << endl;
}
else{
cout << "Falsche Eingabe" << endl;
}
for(int i = rows; i > 0; i--)
{
cout << i << "|" ;
for (int j = 0; j < cols; j++){
if(Field[j] == 1){
cout << "*"; } cout << " ";
}
cout << "\n\n\n"; } cout << "0" << "|";
for(int j = 1; j < cols; j++)
{
cout << "---------" << j;
}
} -
abstand:=(x2−x1)2+(y2−y1)2
wie macht man das,danke
-
-
-
#include <iostream>
using namespace std;
void getMenu(){
cout<<"Menu"<<endl;
cout<<"1 - Anzahl festleegen"<< endl;
cout<<"2 - Zahlen eingeben" << endl;
cout<<"3 – Minimum anzeigen"<< endl;
cout<<"x – Beenden"<< endl;
}
void getMenu2(){
cout<<"a = 1" << endl;
cout<<"b = 2" << endl;
cout<<"c = 3" << endl;
}
int main()
{
int wahl;
char wahl2;
int zahl1;
int zahl2;
int zahl3;
getMenu();
cout<<"Ihre Wahl: ";
cin>> wahl ;
while (wahl != 'x'){
if(wahl == 1){
getMenu2();
cout<<"Antwort: ";
cin>> wahl2;
cout<<endl;
}
else if(wahl == 2)
{
if(wahl2 =='a'){
cout<<"bitte geben Sie die Zahl ein: ";
cin>>zahl1;
break;
}
else if (wahl2 =='b'){
cout<<"bitte geben Sie die erste Zahl ein: ";
cin>>zahl1;
cout<<"bitte geben Sie die zweite Zahl ein: ";
cin>>zahl2;
cout<<endl;
}
else if (wahl2 =='c'){
cout<<"bitte geben Sie die erste Zahl ein: ";
cin>>zahl1;
cout<<"bitte geben Sie die zweite Zahl ein: ";
cin>>zahl2;
cout<<"bitte geben Sie die dritte Zahl ein: ";
cin>>zahl3;
cout<<endl;
}
else{
cout<<"Nochmal waehlen";
}
}
else if(wahl == 3)
{
if (wahl2 =='a'){
cout<<"die kleinste Zahl ist : "<< zahl1 <<endl;
}
else if(wahl2 =='b'){
if (zahl1 < zahl2){
cout<<"die kleinste Zahl ist: "<< zahl1 <<endl;
}
else{
cout<<"die kleinste Zahl ist: "<< zahl2 <<endl;
}
}
else if(wahl2 =='c'){
if (zahl1 < zahl2 && zahl1 < zahl3){
cout<<"die kleinste Zahl ist: "<< zahl1 <<endl;
}
else if(zahl1 < zahl2 && zahl3 < zahl1){
cout<<"die kleinste Zahl ist: "<< zahl3 <<endl;
}
else{
cout<<"die kleinste Zahl ist: "<<zahl2 <<endl;
}
}
else{
cout<<"error"<<endl;
}
}
else{
cout<<"danke"<<endl;
break;
}
getMenu();
cout<<"Ihre Wahl: ";
cin>> wahl;
}
}
Statische C-Arrays
in C und C++
Geschrieben