Advertisement
Guest User

Untitled

a guest
Oct 1st, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Eiffel 1.54 KB | None | 0 0
  1. note
  2.     description : "root class of the application"
  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.     powerset(s : LINKED_SET[INTEGER]) : LINKED_SET[LINKED_SET[INTEGER]]
  18.         local
  19.             cp : LINKED_SET[INTEGER]
  20.         do
  21.             create Result.make;
  22.             Result.compare_objects
  23.             Result.put(s)
  24.  
  25.             across s as i loop
  26.                 create cp.make;
  27.                
  28.                 cp.compare_objects
  29.                 cp.copy(s)
  30.                 cp.prune(i.item)
  31.                 Result.merge(powerset(cp))
  32.             end
  33.         end
  34.  
  35.     make
  36.         local
  37.             n, t, i : INTEGER
  38.             s       : LINKED_SET[INTEGER]
  39.             ps      : LINKED_SET[LINKED_SET[INTEGER]]
  40.         do
  41.             create s.make
  42.             s.compare_objects
  43.            
  44.             io.read_integer
  45.             n := io.last_integer
  46.            
  47.             from i := 0 until i >= n loop
  48.                 io.read_integer
  49.                 t := io.last_integer
  50.                 s.put(t)
  51.                 i := i + 1
  52.             end
  53.            
  54.             ps := powerset(s)
  55.            
  56.             across ps as it loop
  57. --                io.put_string("{ ")
  58.                 across it.item as j loop
  59.                     io.put_integer(j.item)
  60.                     io.put_string(", ")
  61.                 end
  62.                 io.put_string("}%N")
  63.             end
  64.         end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement