Homework | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Homework

The picture link is my homework from my professor at the university and I do not know how to solve the duty. All that is required is the work of the text to be answered, such as in the picture, and it must be solved because it has 5 marks - http://i.imgur.com/ynWRPL3.jpeg

14th May 2018, 8:42 PM
Ahmad Nader
Ahmad Nader - avatar
22 Answers
+ 9
It's not that difficult. No one here will write the complete code for you, we all have real lives and duties :P But this will help you to get started: First, how to create a matrix... Second, how to create random int values... Then you need to modify the values on certain conditions, that should be easy when you mastered the first two tasks. Fourth, easy if you managed the third task, two simple nested for loops will do the trick. Just post your code when you're stuck at any point and someone will help you. https://code.sololearn.com/cYUipXJfwAbN/?ref=apphttps://code.sololearn.com/cU6QfO5ihO3Q/?ref=app
14th May 2018, 8:58 PM
Tashi N
Tashi N - avatar
+ 6
You removed your old posts?
14th May 2018, 8:46 PM
Tashi N
Tashi N - avatar
+ 6
Okay, fair enough :)
14th May 2018, 8:48 PM
Tashi N
Tashi N - avatar
+ 6
Keep in mind plagarism is academic dishonesty, and could get you a failing grade or kicked out of university. You should not copy the solution Andrea gave.
14th May 2018, 10:07 PM
Rrestoring faith
Rrestoring faith - avatar
+ 5
I'm not good in C++ but I'll try to find examples on the playground which you can use to get started.
14th May 2018, 8:50 PM
Tashi N
Tashi N - avatar
+ 5
Rrestoring faith he should try to understand it...but if he is going to CTRLC CTRLV he won't go far away in life...programming is not copy & paste
14th May 2018, 10:25 PM
Andrea Simone Costa
Andrea Simone Costa - avatar
+ 4
The instructions basically say to just iterate over each element. If an element is even, multiply it by 2. If an element is odd, multiply it by -1 (change its sign). After that, sum up each row for the answer. For example, let's say one of your rows is [4, -1, 3]. 4 is even, so you multiply it by 2. That gives you 8. -1 is odd, so you multiply it by -1. That gives you 1. 3 is odd, so you multiply it by -1. That gives you -3. If you sum up "8 + 1 - 3", you will get 6. You do that for each row. You can achieve this easily with a nested for-loop.
20th May 2018, 5:23 AM
Fox
Fox - avatar
+ 2
You may want to look into using arrays and a few if statements here a link I just pulled from google on arrays also see the other stuff like working with for loops. https://www.tutorialspoint.com/cprogramming/c_arrays.htm may give you an idea
14th May 2018, 8:51 PM
Ben
Ben - avatar
+ 2
Ahmad Nader I can tell that you are having some trouble with your assignment. What do you know how to do and we can go from there?
14th May 2018, 9:25 PM
Evan Martine
14th May 2018, 9:40 PM
Andrea Simone Costa
Andrea Simone Costa - avatar
+ 1
Hmm, Sorry I dont have any experience with c++. If only the question were in java
14th May 2018, 9:41 PM
Evan Martine
+ 1
Did you just change your profile pic xD? Also just letting you know this app can teach you c++
14th May 2018, 9:44 PM
Evan Martine
0
No
14th May 2018, 8:44 PM
Ahmad Nader
Ahmad Nader - avatar
0
Yes, because you asked me to clarify what is required of the link, I did a new post , please if you can answer it answer it
14th May 2018, 8:48 PM
Ahmad Nader
Ahmad Nader - avatar
0
You will answer it ?
14th May 2018, 8:49 PM
Ahmad Nader
Ahmad Nader - avatar
0
Thank you , if you now someone good in c++ send it to him , please 😊🌸
14th May 2018, 8:51 PM
Ahmad Nader
Ahmad Nader - avatar
0
All this I know It but this homework is difficult and too long and I don’t have enough time because I have exams
14th May 2018, 8:53 PM
Ahmad Nader
Ahmad Nader - avatar
0
I don’t understand anything from these posts 😢
14th May 2018, 9:07 PM
Ahmad Nader
Ahmad Nader - avatar
0
I just need someone answer the picture
14th May 2018, 9:26 PM
Ahmad Nader
Ahmad Nader - avatar
0
Andrea Simone thank you very much 🌸
14th May 2018, 9:43 PM
Ahmad Nader
Ahmad Nader - avatar