n  =  20;
uu  =  10;        
pp  =  10;        
A  =  {};
For[u = uu, 
      u ≤ 
        uu + n, u++, 
B  =  {}; 
For[p = pp, 
        p ≤ pp + n, p++, 
P  =  
          Table[1, {p}]; 
u1  =  
          0; 
c  =  0; 
While[
          u1 < (p/2), 
For[i = 1, 
              i ≤ p  &&  
                u1 < (p/2), i++, 
If[
                  (Subscript[P, [[i]]]) == 1, 
x  =  
                    Random[Integer, {1, 
                        u}]; 
c++; 
If[
                    x == 
                      1, 
(Subscript[P, [[i]]]) = 
                      0; 
u1++;
];
];
];
]; 
B  =  
          Append[B, c];
]; 
A  =  
        Append[A, B];
]
Export["D:\Andrea\esperimento.dat", 
        A, "Table"];
Export["D:\Andrea\grafico.eps", ListPlot3D[A]]