+ 1
how can i write 1 times 1, 2 times 2 , 3 times 3 in page with for loop? for example (1223334444)
2 odpowiedzi
+ 3
C# LINQ One-Liner〰
Enumerable.Range(1, 4)
.SelectMany(n =>
Enumerable.Repeat(n, n)).ToList()
.ForEach(n => Console.Write(n));
💡 Demo
https://code.sololearn.com/cP12vDMgTn9E/?ref=app
+ 3
for(unsigned i = 1; i < n; ++i)
for(unsigned j = 0; j < i; ++j)
cout << i;