How can i make this exercise?

I stuck at this exercise: http://www.kepfeltoltes.eu/view.php?filename=544Screen_Shot_2017_09_24.png

http://www.kepfeltoltes.eu/view.php?filename=672Screen_Shot_2017_09_24.png

I tried some solutions but nothing. I'm a beginner in programming. How can i answer this exercise?

Thanks for the answers! 😀