Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Korowai
unregistriert
Zitat von »Korowai«
Variablen (int)
Korowai
unregistriert
Korowai
unregistriert
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
#include <iostream> #include <conio.h> #include <iterator> #include <list> #include <vector> #include <list> #include <stdio.h> #include <cstdlib> #include <ctime> #include <string> #include "A.hpp" #include "B.hpp" using namespace std; A Mobil_A[4]; B Mobil_B[4]; vector<string> Auswahlname; vector< int Mobilanzahl; void Namenseingabe (int &Mobilanzahl) { int Verteilung=0; int A_Verteilung; int B_Verteilung; for (int x=0;x<Mobilanzahl;x++) { Verteilung=Verteilung+1; if (Verteilung<Mobilanzahl/2) { cout << "Name von A "<<Verteilung<<" eingeben:"<<endl; cin >> Mobil_A[x].name; } else { cout << "name von B "<<Verteilung<<" eingeben:"<<endl; cin >> Mobil_B[x].name; } } return; } int main() { string Name; srand(time(0)); Mobilanzahl=rand()%3+1; cout << "Es sind " << Mobilanzahl <<" vorhanden."<<endl; cout << "Namen abfragen:"<< endl; Namenseingabe(Mobilanzahl); for (int x=0;x<4;x++) { Mobil_A[x].Namensausgabe(); Mobil_B[x].Namensausgabe(); } cout << "welche Namen sollen ein Geschwader bilden?"<<endl; for (int x=0;x<Mobilanzahl;x++) { cin >> Name; cout << endl; Auswahlname.push_back(Name); } return 0; } |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#ifndef A_HPP_INCLUDED #define A_HPP_INCLUDED #include <string> class A { public: std::string name; bool Geschwadermitglied; int Geschwaderziel; int Geschwaderzeit; A(); ~A(); void Namensausgabe(); }; #endif // A_HPP_INCLUDED |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#ifndef B_HPP_INCLUDED #define B_HPP_INCLUDED #include <string> class B { public: std::string name; bool Geschwadermitglied; int Geschwaderziel; int Geschwaderzeit; B(); ~B(); void Namensausgabe(); }; #endif // B_HPP_INCLUDED |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#include "A.hpp" #include <iostream> #include <string> using namespace std; A::A() { std::string name=" "; bool Geschwadermitglied=false; int Geschwaderziel=0; int Geschwaderzeit=0; }; A::~A() { }; void A::Namensausgabe() { cout << " Name: "<< name<<endl; return; } |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#include "B.hpp" #include <string> #include <iostream> B::B() { std::string name=" "; bool Geschwadermitglied=false; int Geschwaderziel=0; int Geschwaderzeit=0; }; B::~B() { }; void B::Namensausgabe() { std::cout << " Name: "<< name<<std::endl; return; } |
Korowai
unregistriert
Werbeanzeige