Advertisement
Guest User

Untitled

a guest
Jun 30th, 2017
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1.  
  2.     class Program {
  3.         private static byte[] Magiya(int chislo) {
  4.             Debug.Assert(chislo >= 0, "Eeee, blyat!");
  5.             if(chislo == 0) {
  6.                 return new byte[] {0x30};
  7.             }
  8.             var i = (int) Math.Ceiling(Math.Log10(chislo + 1));
  9.             var otvet = new byte[i];
  10.             while(chislo != 0) {
  11.                 i -= 1;
  12.                 otvet[i] = (byte)(0x30 + chislo % 10);
  13.                 chislo /= 10;
  14.             }
  15.             return otvet;
  16.         }
  17.  
  18.         static void Main(string[] args) {
  19.             using(var fs = new FileStream("text.txt", FileMode.Create, FileAccess.Write))
  20.             using(var bw = new BinaryWriter(fs)) {
  21.                 Random rnd = new Random();
  22.  
  23.                 for(uint i = 0; i < 10000; i++) {
  24.                     bw.Write(Magiya(rnd.Next(0, 10000)));
  25.                     bw.Write((byte) 0x20);
  26.                 }
  27.             }
  28.             System.Diagnostics.Process.Start("text.txt");
  29.         }
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement