X
X
x973cp1162018-10-18 21:13:34
C++ / C#
x973cp116, 2018-10-18 21:13:34

Problem with arrays and loop. D / Z (2 course techie). How to do?

Get an n*m matrix randomly between -50 and 50. Calculate the sum and number of positive elements of a c# matrix.
How to calculate the sum and number of positive matrix elements?
Matrix already written:

int n, m, sum;
            Console.WriteLine("Введите n");
            n = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Введите m");
            m = Convert.ToInt32(Console.ReadLine());
            sum = 0;
            Random r = new Random();
            int[, ]a = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    a[i, j] = r.Next(-50, 50);
                    Console.Write("\t" + a[i, j]);
                }
                Console.WriteLine();
            }

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander Taratin, 2015-08-03
@antokha

Maybe it's better to just write something to the session, for example, $_SESSION['auth'] = 1

Yes.
They cannot, the user knows only the session ID on the server, he cannot change the data in it.

A
Alexander, 2015-08-03
Madzhugin @Suntechnic

Forge session == forge session id cookie. If an attacker has session cookies, then it doesn't matter how you store authorization in the session. If they are not there, then the fact that the session is just an authorization flag will not help him in any way. In terms of security, these two methods - storing auth=1 or some kind of hash there are no different. Well, it’s a bit of a stretch to say that auth=1 is a little safer, because you store the hash of the password, which means that if the session files are received, the attacker has a hypothetical chance to try to recover the password using the hash if he gets the session files .

R
Roma Naumenko-Vahnitsky, 2015-08-03
@DipperTeam

Firstly, before checking, you need to filter the forms, you can slip different javascript scripts and dangerous code that can hack your site...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question