Aufgaben:

Schreiben Sie ein Programm, dass quadratische Gleichungen mit Pointern löst.

Programmieren Sie Zahlenraten: Der Computer generiert eine Zufallszahl zwischen 1 und 100, die der Spieler erraten muss. In jedem Durchgang wird ermittelt ob die Zahl zu groß oder zu klein war. Benutzen Sie
#include <time.h>
srand(time(NULL)); zahl = rand()%100+1;


Bestimmen Sie die Primfaktorzerlegung einer eingegebenen Zahl!

Lösungen:

Quadratische Gleichungen lösen: https://onlinegdb.com/Skn-B52fV

Zahlenraten: https://onlinegdb.com/Bkziw9nGN

Primfaktorzerlegung: https://onlinegdb.com/Skf7Tc2G4

Folgende Aufgabe stelle ich euch über die Weihnachtsferien:

Schreibt ein Programm, dass Primzahlen farmen kann. Dazu benötigt ihr folgende Dinge:

  • bool isPrime(int zahl)
  • int nextPrime(int zahl)
  • int nthPrime(int zahl)

Das ganze soll so aussehen, dass ihr eine Eingabe macht, in der ihr die 420te  oder die 42te oder die 1000te Primzahl haben wollt. Die geforderte Primzahl wird dann ausgerechnet und auf der Konsole ausgegeben.

Das ganze soll via Call by Reference gemacht werden. Am besten optimiert ihr auch (wenn möglich) eure nextPrime bzw. isPrime Funktion, da das bei großen Zahlen durchaus lange dauern kann bis es ein Ergebnis gibt.

Bonus: Speichere alle Primzahlen in einem Array ab und gib sie bis zur gesuchten x-ten Primzahl am Ende auf der Konsole aus (durch Komma getrennt).

Viel Spaß und Erfolg beim Programmieren und Frohe Weihnachten!

Call by Reference Beispiel aus der Vorlesung: https://onlinegdb.com/SJQtC_AyV

Once there was a little rose in a beautiful and wide garden. Every day she saw the sun rising and was wondering, why she can’t be that much impressive like the big yellow thing above her.
Once she was so sad that she is just a little plant under many other plants in this huge garden with all these nice plants and trees that her neighbor, a shy but lovely tulip, went over to comfort her.
She asked: «Why are you so sad? You are such a beautiful rose, u should be proud of yourself. Don’t look at all these strange flowers around you. Do you see the yellow one right next to the house? She is one of the biggest at day and is always following the sun, but there is still nobody who bought her.»
The rose looks around and found this big sunflower. She answered: «But how is this possible? She is the best and biggest from all of us. She must be the first who finds a new home.» The tulip replied: «Maybe you are right, but the ones who are buying us are humans. They don’t care much about strength or how tall you are. They just see one thing in us – hope. They take us to dinners, to dates, to the church, sometimes even to the undertaker, but in the end, everyone thinks about hope when they see us. So be proud of you and shine bright, but don’t try to copy the sun. Be always yourself and something special in your own way. Then you will be the happiest rose ever.»
The rose was so happy about these words that she was smiling all the day.
Even the next day, she was in a perfect mood, but still nobody came to look at her.
The sun was going to change her place with her husband, the moon, and the rose was getting ready for the night. Then, yes, exactly in this moment a small little guy came across and said: „This one! I really need this one! She is just perfect.» The rose didn’t know what to do and the gardener came and gave her to this smart guy. This guy took her on a small glass and brought her to a house. It was late, time for dinner. She didn’t know what to expect and was a bit frightened because of the dark. But suddenly the door got opened and she stood on a table. Next to her a wonderful young lady who couldn’t take her eyes from the rose. That made her so happy and proud, that she began smiling and shining.
Every day this week she saw her guy and the lady. Saw, how these two are, watched TV, talked, cuddled or just watched this little rose. And even when the rose was old and not that beautiful, but still shining, the lady said at dinner: „Sweetheart, I know the rose is old and dry, but I can’t throw her away. She remembers me at you every single second. I can’t do it. Do you know what to do?» The guy was clever and took a nice old book with some empty pages. He took the rose in the middle of it and mentioned: „I can’t keep you alive forever my little rose, but I can keep you in this book, so that my girlfriend can remember you.»
So she was in this book and stood right next to a picture of the couple she made (happy).
The people got old, got children and grandchildren and one day a little finger found the page with the rose. He was smiling about the beauty and the rose thought back about this one day, when a small and shy, but lovely tulip came over to her…

A little rose.pdf

Este contenido está protegido por contraseña. Para verlo introduce tu contraseña a continuación: