C# | Sololearn: Learn to code for FREE!
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.

11th Feb 2020, 7:03 AM
Ученый Каменого Века
Ученый Каменого Века - avatar
15 Answers
+ 10
for(int i = 0; i < 16; i++) { Console.WriteLine(i + 1); }
11th Feb 2020, 7:05 AM
A͢J
A͢J - avatar
+ 3
джокер ] Can you clarify your doubt? Now I am not getting.
11th Feb 2020, 7:52 AM
A͢J
A͢J - avatar
+ 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
11th Feb 2020, 9:55 AM
Ученый Каменого Века
Ученый Каменого Века - avatar
+ 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.
11th Feb 2020, 10:12 AM
Ipang
+ 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)
11th Feb 2020, 4:58 PM
Gordon
Gordon - avatar
+ 2
for (int i = 1 ; i <= 16; Console.WriteLine(i++)) ;
23rd Feb 2020, 5:45 PM
Neuromonkey
Neuromonkey - avatar
+ 1
Can you please elaborate some more details on the idea? I am not understanding why you need so many for-loops.
11th Feb 2020, 8:41 AM
Ipang
+ 1
I'm not an English-speaking, so I'm studying it, too.
11th Feb 2020, 9:56 AM
Ученый Каменого Века
Ученый Каменого Века - avatar
0
Yes imeno so I need to, but the number has 16 values, 25, 36, and so on
11th Feb 2020, 5:38 PM
Ученый Каменого Века
Ученый Каменого Века - avatar
0
for(int i = 0; i < 16; i++) Console.WriteLine(i + 1);
13th Feb 2020, 5:16 AM
Jagbir singh
Jagbir singh - avatar
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
24th Apr 2020, 11:07 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
0
int x=1; do{Console.WriteLine(x) x++ } while(x==17);
25th May 2020, 11:26 PM
Akinola Ridwan Oladimeji
0
use operation "For". for(Int32 i=0; I<16;I++)
10th Aug 2021, 6:53 PM
Савосин Захар Александрович
Савосин Захар Александрович - avatar
- 1
thank you but not this. I need the program to be able to work with 16 (for)
11th Feb 2020, 7:10 AM
Ученый Каменого Века
Ученый Каменого Века - avatar
- 1
For(x=1; x<=16; x++) { Console.Writeline(x); }
20th Oct 2020, 8:53 AM
Daberechukwu Ibeakanma
Daberechukwu Ibeakanma - avatar