0

[SOLVED] "That's odd" in C programming

Hi, I'm trying to solve "That's odd" using C. From my understanding, the first input is N length. For example, if the input is 5, that means the length is 5, and I need to evaluate the next 5 numbers whether they are even or odd. However, the first test case shows that the first input is 5,which means the length is 5, but the available data are only 2 (namely 190 and 88 in this test case). 1- Is my understanding regarding this question correct? (Eg. If the length is 5, then the next input should have 5 more input .) 2- If the length is 5, and the data input is only 190 and 80, how do I deal with the other 3 empty spaces? If I just use scanf to wait for the user input, I think the program will just wait and get stuck there as there is no further input. Thanks in advance!

27th Jan 2020, 3:25 AM
Ahmad Daniel Sulaiman
Ahmad Daniel Sulaiman - avatar
7 Antworten
+ 4
Ahmad Daniel Sulaiman If you swipe/scroll down inside the input box on the test case 1 you will see the other three numbers, they are there: 43, 53, 63. Use diego Code's approach to read n and n lines.
27th Jan 2020, 6:52 AM
Mihai Apostol
Mihai Apostol - avatar
+ 3
Thanks Mihai Apostol! Didn't know that!
27th Jan 2020, 11:14 AM
unChabon
unChabon - avatar
+ 2
1. You are right... But.. 2. It worked fine with something like: scanf("%d", &q); for(i = 0; i < q; i++){ scanf("%d", &num); .... } so, they made the test case #1 with 3 empty lines ( ?)
27th Jan 2020, 4:37 AM
unChabon
unChabon - avatar
+ 2
Mihai Apostol Thanks! I didn't know that it's possible. It's because there's no arrow or some kind of indication available. So it means for N length , there will be N number of data. diego Code Thanks for the tips. I finally managed to solve it but the code is slightly different .Just to clarify your code ,is it for unknown number of input?
27th Jan 2020, 1:21 PM
Ahmad Daniel Sulaiman
Ahmad Daniel Sulaiman - avatar
+ 2
Ahmad Daniel Sulaiman You're welcome. If diego Code allows me I will explain his code. No, it is for defined number of inputs, only he used q instead of n for the name of the variabile. So he first reads q and then reads q numbers in a loop.
27th Jan 2020, 1:30 PM
Mihai Apostol
Mihai Apostol - avatar
+ 1
Mihai Apostol Owhh..understood! Thanks! I've marked this as solved.
27th Jan 2020, 2:38 PM
Ahmad Daniel Sulaiman
Ahmad Daniel Sulaiman - avatar
+ 1
Ahmad Daniel Sulaiman Again you're welcome. Good practice marking it Solved.
27th Jan 2020, 2:41 PM
Mihai Apostol
Mihai Apostol - avatar