investigated the options to return an array from a function

This commit is contained in:
2021-10-16 09:19:44 +02:00
parent d3138a4b13
commit d6287d6002
10 changed files with 127 additions and 0 deletions
@@ -0,0 +1,11 @@
#include <iostream>
using namespace std;
int main(){
for(int i=1; i<=100;i++){
if(i%2!=0) continue;
cout<<i<<endl;
}
}
+24
View File
@@ -0,0 +1,24 @@
#include <iostream>
#include <string>
using namespace std;
struct Tier{
uint8_t id;
string name;
bool operator == (const Tier& cmp) const {return id==cmp.id;}
bool operator < (const Tier& cmp) const {return id-cmp.id;}
string to_string(){return "ID: "+id+(name.length()>0?("Name: "+name):"")+"\n";}
};
int main(){
Tier tiere[50];
cout<<"Erstelle Liste\n";
for(int i = 0;i<50;i++){
cout<<"Erstelle index "<<i<<endl;
tiere[i].id=i+1;
}
for(Tier tier:tiere){
cout<<tier.to_string()<<endl;
}
system("pause");
}
Binary file not shown.