Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Eiffel 1.83 KB | None | 0 0
  1. note
  2.     description : "DnA_ass10 application root class"
  3.     date        : "$Date$"
  4.     revision    : "$Revision$"
  5.  
  6. class
  7.     APPLICATION
  8.  
  9. inherit
  10.     ARGUMENTS
  11.  
  12. create
  13.     make
  14.  
  15. feature {NONE} -- Initialization
  16.  
  17.     make
  18.             -- Run application.
  19.         local
  20.             t_fix, t, input_length, i, j: INTEGER
  21.             input_list: LIST[STRING]
  22.             data: ARRAY[INTEGER]
  23.             output: ARRAY[INTEGER]
  24.             dom: DOMINANTS
  25.  
  26.         do
  27.             create data.make (0, 0)
  28.             io.read_integer
  29.             t_fix := io.last_integer                        -- first line input (#testcases)
  30.             create output.make (1, t_fix)                   -- t_fix outputs
  31.  
  32.  
  33.             -- For each test case t...
  34.             from t := t_fix until t < 1 loop
  35. io.put_string ("reading input...%N")
  36.             -- creates an array of arrays 'data', with the input values of instance 't'
  37.             --
  38.  
  39.                 -- read input into input_list
  40.                 io.read_line                                -- second/third/.../t+1 line input
  41.                 input_list := io.last_string.split (' ')
  42.  
  43.                 -- create array 'data' of input length
  44.                 input_length := 2* (input_list[1].to_integer)
  45.                 data.make (0, input_length - 1) -- array for inputs
  46.  
  47.  
  48.                 -- store inputs in 'data'
  49.                 from i := 0 until i >= input_length loop
  50.                     data[i] := input_list[i + 2].to_integer
  51.                     i := i + 1
  52.                 end
  53. io.put_string ("input read!%N")
  54.             --
  55.             -- inputs of instance 't' are now stored in 'data'
  56.  
  57.  
  58.                 -- COMPUTATION
  59.  
  60.                 create dom.make_with_values (input_length, data)
  61. io.put_string ("calculating solution...%N")
  62.                 output[t_fix - t + 1] := dom.ans
  63. io.put_string ("solution found!%N----- ")
  64. io.put_integer (t_fix - t + 1) io.put_string (" of ") io.put_integer (t_fix)
  65. io.put_string (" -----%N")
  66.  
  67.             t := t - 1
  68.             end -- of 't' loop
  69.  
  70.             -- OUTPUT
  71.             from i := 1 until i > t_fix loop
  72.                 io.put_integer (output[i])
  73.                 if i < t_fix then
  74.                     io.new_line
  75.                 end
  76.                 i := i + 1
  77.             end
  78.  
  79.  
  80.         end -- of 'make'
  81.  
  82.     end -- of 'APPLICATION'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement