0
Extra terrarian
The code just says no output. I have checked but i can't find any mistakes https://code.sololearn.com/c64T8TSiwdjr/?ref=app
21 Respostas
0
use this instead :
for(int i = y-1; i>=0; i--)
because in an array 'arr', the index of the last item is arr.Lenght-1.
+ 2
I made this code for you, it has a description of each step. You can find more info in Microsoft's documentation page.
https://code.sololearn.com/cWu9Kk2Ejlx8/?ref=app
+ 1
I think you should change the condition in the loop, use i>=0 instead.
+ 1
no, I tried. the for loop should look like that:
for(int i = y-1; i>=0; i--)
+ 1
Oh thanks
+ 1
To both
+ 1
namespace SoloLearn
{
class Program
{
static public string reverse(string s)
{
if (s.Length != 0) // if the string is NOT empty
{
char[] charArray = s.ToCharArray(); // creates CharArray from string s
Array.Reverse(charArray); // uses native Array.Reverse method
return new string(charArray); //returns string
}
else //if s is empty
{
return s; //returns empty string
}
}
static void Main(string[] args) //main
{
string reverseme = "This should be reversed"; //created string
Console.WriteLine(reverse(reverseme)); //using the method
}
}
}
+ 1
Ok thanx
0
But it would write the word the same as before
0
Now it says unhandled exception please help
0
Well, again show me your code so I can see the exception.
0
I edited it did it not change
0
Just flip the greater than sign and you will see
0
What greater sign? Did you use the code that I wrote?
0
I couldn't really understand it
0
Can't it be done the way I am doing
0
Go to the top right corner. There are three points. Tap on "save" after you edit it.
0
Try it now
0
The code in the question
0
static void Main(string[] args)
{
string x = Console.ReadLine();
int y = x.Length ;
for(int i = y ; i > 0 ; i--)
{
Console.WriteLine(x[i]);
}
Is that your code?