Answer the question
In order to leave comments, you need to log in
Is it possible to give an int variable ANY integer value, for example from a span (C++ && Java)?
int number, i, N;
if (i == 0 || i == (number * N)) {...}
if (i == 1 || i == (1 + number * N)) {...}
if (i == 2 || i == (2 + number * N)) {...}
/*
мне надо, чтобы N могла равняться любому целому числу одновременно (!)
в математике это можно, это легко, а можно ли так сделать в Java? Ну, или можно пример на C++?
*/
if (i == 0 || i == (number) || i== (number * 2) || i == (number * 3)) {...} //и так далее
if (i == 1 || i == (1 + number) || i== (1 + number * 2) || i == (1 + number * 3)) {...} //и так далее
Answer the question
In order to leave comments, you need to log in
You don’t need to get into programming, apparently, apparently you didn’t hear about the remainder when dividing in elementary school (if we talk about mathematics)
//if (i == 0 || i == (number) || i== (number * 2) || i == (number * 3)) {...} //и так далее
if(i == 0 || i % number == 0) {...}
//if (i == 1 || i == (1 + number) || i== (1 + number * 2) || i == (1 + number * 3)) {...}
if (i == 1 || i % number == 1) {...}
// Ну и на последок
int mod = i % number;
Is it possible to give an int variable ANY integer value
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question