+ 1
How I can write a program in CS with this output (COMPUTER IS A WORLD OF SCIENCE)?
C O M P U T E R I S A W O R L D O F S C I E N C E
2 Respuestas
+ 1
The following works:
using System;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
string msg = "computer is a world of science";
msg = msg.Replace(" ", "").ToUpper();
int index = 0;
int maxLen = 5;
int len;
for (len = 1; len <= maxLen; len++) {
Console.WriteLine(msg.Substring(index, len));
index += len;
}
for (len-=2; len >= 1 && index < msg.Length; len--) {
Console.WriteLine(msg.Substring(index, len));
index += len;
}
}
}
}
0
So nice 😍
Thanks a lot Mr. Josh Greig