bonjour je suis en Java
Pour le 2ème test j’obtient bien
-12
-5
-1337
-12
Ceci dit malgré que tout les autres test fonctionne pour celui ci il me trouve -1 ( qui viendrait du -12 je pense …)
j’utilise
String tab = temps.split(" ");
puis
int val = Integer.parseInt(tab[i]);
someone helps me please!! i can’t take the numbers from the vector of char.. i tried with sscanf but it always begin from the beginning of temps and it returns me only the first value..
I think someone has posted about this above but as my french is terrible I cant be sure XD I have noticed that the second test case has an integer with the value if “-1337” but the problem statement makes it clear that the lowest a number should go is “-274”. Just thought I should let someone know. @SaiksyApo maybe?
Don’t I have to at some point convert the input String into an int? (Java). I’m having trouble doing this.
int num = Integer.parseInt(temps);
That’s what I initially put on there, but it doesn’t work. Mainly because there are multiple numbers. How can I convert them in order to later be able to compare absolute values?
Or, do I have to do this at all?
Anyway, fairly beginner programmer here, could use a hint.
I am working on the Temperatures puzzle in Java on the website, and when I go to compile it gives me the following error message. Thanks for your help!
Exception in thread “main” java.lang.NumberFormatException: For input string: “1 -2 -8 4 5”
at java.lang.NumberFormatException.forInputString on line 65
at java.lang.Integer.parseInt on line 580
at java.lang.Integer.valueOf on line 766
at Solution.main on line 22
One question dealing with this puzzle do you think I need to create another integer in the puzzle or do I need to convert the string temps into an integer to work with int n?
Thanks SaikskyApo you really helped me out.. One more question how do you split it do I have to make another string name. Because I’m trying but, it’s not coming out right here’s what I have right now:
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine()); // the number of temperatures to analyse
string temps = Console.ReadLine(); // the n temperatures expressed as integers ranging from -273 to 5526
int[] tempsO = new int[n];
int t = Convert.ToInt32(Console.ReadLine());
string[] temps1 = new string[(t)temps];
try
{
}
catch
{
Console.WriteLine("ERROR, my friend... Don't let me freeze!");
}
//int.Parse(Console.ReadLine());
// Write an action using Console.WriteLine()
// To debug: Console.Error.WriteLine("Debug messages...");
Console.WriteLine("result");
Console.WriteLine("PAK");
Console.ReadKey();
}
if you’re not telling us what’s blocking you, we’ll have a hard time helping you. Check the history of this topic, there should be plenty of hints to help you manage the puzzle.
Would it be possible that there is still a malfunction with the making system for this code? On the test samples I get 100% however when submitted it is returned with a 81 or 91% success depending on alterations I make.
Would there be any way to ask for someone to check the code?