New course! Every coder should learn Generative AI!
Try a free lesson+ 3
C#
Hello. Question, how to make a loop with iteration of 16 numbers.
15 Answers
+ 10
for(int i = 0; i < 16; i++) {
Console.WriteLine(i + 1);
}
+ 3
джокер ] Can you clarify your doubt? Now I am not getting.
+ 2
I study programming and solve puzzles in my spare time. in the task I'm solving, I can't solve one problem, and it requires me to go through a lot of options, and it looks like this:
1234
1243
2134
2143
and so on to the end
+ 2
You may write in your native language if it feels more comfortable to explain. Others can use translator tools to understand what you wrote.
I'm not sure about that puzzle you're talking about. But if you want to check for variations of digits from that number; then perhaps you can search for permutation.
+ 2
This is like mastermind game.
For four-digit, you create three-level nested loops,
a pseudo-code:
for i from 1 to 4
for j from 1 to 4
for k from 1 to 4
(use if-else to check if digit duplicate, if so, use continue to pass to next iteration)
+ 2
for (int i = 1 ; i <= 16; Console.WriteLine(i++)) ;
+ 1
Can you please elaborate some more details on the idea? I am not understanding why you need so many for-loops.
+ 1
I'm not an English-speaking, so I'm studying it, too.
0
Yes imeno so I need to, but the number has 16 values, 25, 36, and so on
0
for(int i = 0; i < 16; i++)
Console.WriteLine(i + 1);
0
If I understand you correctly джокер ], you have 16 different numbers which have to be in a specific order to solve the puzzle?
If that is the case you are looking for recusion. I prepared an example with an array of numbers and a callback telling me if we found a solution. It combines all of the numbers by reminding which ones are used and jumping to the next position. The example uses four numbers, but it will work with more...
https://code.sololearn.com/cDWZm0DJigcs/?ref=app
0
int x=1;
do{Console.WriteLine(x)
x++
}
while(x==17);
0
use operation "For".
for(Int32 i=0; I<16;I++)
- 1
thank you but not this. I need the program to be able to work with 16 (for)
- 1
For(x=1; x<=16; x++) {
Console.Writeline(x);
}