please help run this C code…
http://www.codechef.com/viewsolution/1944333
producing runtime error… works well on my pc…
PLEASE HELP…
please help run this C code…
http://www.codechef.com/viewsolution/1944333
producing runtime error… works well on my pc…
PLEASE HELP…
@hitesh091 your logic is right.but you have used an array b[max] where max=100 which is main cause for SIGSEGV error i.e. Segmentation fault(using array index out of limit) because number of test cases in problem is 1000 there just declare b as b[1002] for a safer side and your code will successfully run.
but what is need to write all output at a time you can output whenever your logic has been done.here you can see your code without such type of output CLICK HERE
ur welcome…
hi…
i want to know how to print decimal numbers after 6 digits of precision in a float-double type.
@hitesh …
it is simple:
you can use double as your datatype for more than 6 digit of precision and use %[n]f as format specifier in printf.where n is number of digit after decimal you want to print .as the example shows
thank u very very much…
One small tweak you can make is instead of storing results in another array, print it directly once you calculate the result.
for : i<-1 to t
scan t
do all the work to get the answer.// logic
print result //instead of storing the result in an separate array. print it here itself.
ex:1-
scan the testcase:
print the answer
scan another testcase
print the answer.
and so on…
why this approach?
think of the problems where answer is very large and there are many test cases.
initialising another array is a waste of space right?
ur welcum