Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <math.h>
- using namespace std;
- struct Baum{
- string Baumart;
- double height;
- int age;
- Baum(string artIn, double heightIn, int ageIn):Baumart(artIn),height(heightIn),age(ageIn){
- }
- void print(){
- cout << Baumart << "; " << height << "; " << age << ";" << endl;
- }
- };
- Baum pflanzen(){
- string t;
- double h;
- int a;
- cout << "Gebe Baumart an:";
- cin >> t;
- cout << "Gebe Baumhoehe an:";
- cin >> h;
- cout << "Gebe Baumalter an:";
- cin >> a;
- return Baum(t,h,a);
- }
- void fibersteller(int n,int *azero, int a, int b){//Spielerei
- *(azero)=a;
- *(azero+1)=b;
- for(int i=2;i<n;i++){
- *(azero+i)=*(azero+i-1)+*(azero+i-2);
- }
- return;
- }
- bool fibonacciSequence(int length, int arr[]){
- if(length<2) return true;
- int i=2;
- while(i<length){
- if(arr[i-2]+arr[i-1]!=arr[i]) return false;
- i++;
- }
- return true;
- }
- void Aufgabe1(){
- pflanzen().print();
- }
- void Aufgabe2(){
- char arr[9]={'.','.','.','.','.','.','.','.','.'};
- int i=1;
- int input=5;
- while(true){
- do{
- cout << i++ << " ";
- }while(i<10);
- cout << endl;
- i=0;
- do{
- cout << arr[i++] << " ";
- }while(i<9);
- i=1;
- cout << endl;
- cout << "Enter new x Position:";
- cin >> input;
- if(input >9 || input <1 ) break;
- if(arr[input-1]=='x') arr[input-1]='.';
- else arr[input-1]='x';
- }
- }
- void Aufgabe3(){
- const static int n=5;
- int arr[n]={1,2,3,5,7};
- //fibersteller(n,&arr[0],1,1);
- if(fibonacciSequence(5, arr)) cout << "Fibonacci Sequenz" << endl;
- else cout << "Nicht Fibonacci Sequenz" << endl;
- }
- int main(){
- Aufgabe3();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement