How can we randomly put 'a','b','c', '0' in a matrix with srand or any other functions? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can we randomly put 'a','b','c', '0' in a matrix with srand or any other functions?

1st Jun 2018, 10:58 AM
Kimiya Nayyeri
Kimiya Nayyeri - avatar
2 Answers
0
I saw your question and tried some things. If you really only want 'a', 'b', 'c' and '0', the code can get much simpler. https://code.sololearn.com/cYMtEn2BzZ1H/?ref=app
1st Jun 2018, 3:35 PM
Matthias
Matthias - avatar
0
I want to code and make a game in which there are some buildings (b), soldiers (s), cars (s) and '0' randomly in matrix.people should enter a row and col .between that coordinates and the 8 nearest elements, one should randomly choosen and will be aimed to shooted (if it is a building after 3 shoots, if it is a car after 2 shoots and if it is a soldier after 1 shoot will be destroyed completely) and chang to ' #'.the game will be finished when there are just '#' and '0' left in the field of warm (matrix). I want help...
1st Jun 2018, 3:58 PM
Kimiya Nayyeri
Kimiya Nayyeri - avatar