Skip to content
Snippets Groups Projects
Commit 50100fea authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Ergänzung (13.4.2023) der Beispiele vom 6.4.2023

parent f28040a9
Branches
Tags
No related merge requests found
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
class TString
{
private:
char *content;
public:
void print ()
{
printf ("%s\n", content);
}
TString (const char *s = "Hello, world!")
{
printf ("Constructing TString object\n");
content = (char *) malloc (strlen (s));
strcpy (content, s);
}
virtual ~TString ()
{
printf ("Destructing TString object\n");
free (content);
content = NULL;
}
};
int bye ()
{
printf ("Bye!\n");
return 0;
}
void do_something ()
{
TString s = "Hallo, Welt!";
s.print ();
}
int main ()
{
for (int i = 0; i < 1000; i++)
do_something ();
return bye ();
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
class TString
{
private:
char *content;
public:
void print ()
{
printf ("%s\n", content);
}
TString (const char *s = "Hello, world!")
{
printf ("Constructing TString object\n");
content = (char *) malloc (strlen (s));
strcpy (content, s);
}
virtual ~TString ()
{
printf ("Destructing TString object\n");
free (content);
content = NULL;
}
};
int bye ()
{
printf ("Bye!\n");
return 0;
}
void do_something ()
{
TString *s = new TString ("Hallo, Welt!");
s->print ();
delete s;
}
int main ()
{
for (int i = 0; i < 1000; i++)
do_something ();
return bye ();
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
class TString
{
private:
char *content;
public:
void print ()
{
printf ("%s\n", content);
}
TString (const char *s = "Hello, world!")
{
printf ("Constructing TString object\n");
content = (char *) malloc (strlen (s));
strcpy (content, s);
}
virtual ~TString ()
{
printf ("Destructing TString object\n");
free (content);
content = NULL;
}
};
int bye ()
{
printf ("Bye!\n");
return 0;
}
int very_important_condition ()
{
return 1;
}
void do_something ()
{
printf ("Hi!\n");
if (very_important_condition ())
{
TString s = "Hallo, Welt!";
s.print ();
}
printf ("Bye?\n");
}
int main ()
{
for (int i = 0; i < 1; i++)
do_something ();
return bye ();
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
class TString
{
private:
char *content;
public:
void print ()
{
printf ("%s\n", content);
}
TString (const char *s = "Hello, world!")
{
printf ("Constructing TString object\n");
content = (char *) malloc (strlen (s));
strcpy (content, s);
}
virtual ~TString ()
{
printf ("Destructing TString object\n");
free (content);
content = NULL;
}
};
int bye ()
{
printf ("Bye!\n");
return 0;
}
int very_important_condition ()
{
return 1;
}
void do_something ()
{
printf ("Hi!\n");
if (very_important_condition ())
{
TString *s = new TString ("Hallo, Welt!");
s->print ();
}
printf ("Bye?\n");
}
int main ()
{
for (int i = 0; i < 1; i++)
do_something ();
return bye ();
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
class TString
{
private:
char *content;
public:
void print ()
{
printf ("%s\n", content);
}
TString (const char *s = "Hello, world!")
{
printf ("Constructing TString object\n");
content = (char *) malloc (strlen (s));
strcpy (content, s);
}
virtual ~TString ()
{
printf ("Destructing TString object\n");
free (content);
content = NULL;
}
};
int bye ()
{
printf ("Bye!\n");
return 0;
}
int very_important_condition ()
{
return 1;
}
void do_something ()
{
printf ("Hi!\n");
if (very_important_condition ())
{
TString *s = new TString ("Hallo, Welt!");
s->print ();
delete s;
}
printf ("Bye?\n");
}
int main ()
{
for (int i = 0; i < 1; i++)
do_something ();
return bye ();
}
#include <iostream>
#include <vector>
int main ()
{
std::vector <int> prime = { { 2, 3, 5, 7, 11 } };
for (auto *p : prime)
std::cout << *p << std::endl;
prime.push_back (13);
prime.push_back (17);
for (auto *p : prime)
std::cout << *p << std::endl;
return 0;
}
#include <iostream>
#include <set>
int main ()
{
std::set <int> prime = { { 2, 3, 5, 7, 11 } };
for (auto &p : prime)
std::cout << p << std::endl;
prime.push_back (13);
prime.push_back (17);
for (auto &p : prime)
std::cout << p << std::endl;
return 0;
}
#include <iostream>
#include <set>
int main ()
{
std::set <int> prime = { { 2, 3, 5, 7, 11 } };
for (auto &p : prime)
std::cout << p << std::endl;
prime.insert (prime.end (), 13);
prime.insert (prime.end (), 17);
for (auto &p : prime)
std::cout << p << std::endl;
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment