473,461 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Russian Sorting Halves Danilin

24 16bit
Russian Sorting Halves Danilin

Russian Sorting Halves and fast and human
sorts 1'000'000 in 2.2 seconds on QB64
sorts 1'000'000 in 0.3 seconds on PureBasic

me interested implementation of algorithm in language C#

number of elements is written to file with c:/N.txt or use variable n
array d(n) can be read from a file or synthesized in a program

Russian Sorting Halves Danilin visualisation

Russian Sorting Halves and fast and human
sorts 1'000'000 in 0.2 seconds on C# Csharp

Expand|Select|Wrap|Line Numbers
  1. // RUSSIAN SORTING HALVES DANILIN
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.IO;
  7. namespace davApp
  8. {
  9.     class Program
  10.     {
  11.         private long age;
  12.         static long[] a;
  13.         static long[] d;
  14.  
  15.         static void Main(string[] args)
  16.         {
  17.             int n = 0;
  18.             // READ NUMBERS
  19.             var inpFile = new StreamReader("N.txt");
  20.             n = Convert.ToInt32(inpFile.ReadLine());
  21.             inpFile.Close();
  22.  
  23.             var age = 1 + Math.Log(n) / Math.Log(2);
  24.  
  25.             Console.WriteLine(n);
  26.  
  27.             a = new long[n + 1];
  28.             d = new long[n + 1];
  29.  
  30.             for (int i = 1; i <= n; i++)
  31.                 d[i] = n - i + 1;
  32.  
  33.             //var rand = new Random();
  34.             // RANDOM [1;n]
  35.             //for (int i = 1; i <= n; i++)
  36.             //    d[i] = rand.Next(1, n);
  37.  
  38.             // READ N LINE FROM FILE
  39.             //inpFile = new StreamReader("ISX.txt");
  40.             //for (int i = 1; i <= n; i++)
  41.             //    d[i] = Convert.ToInt64(inpFile.ReadLine());
  42.             //inpFile.Close();
  43.  
  44.             // WRITE ON SCREEN
  45.             int m = Math.Min(n, 20);
  46.             for (int i = 1; i <= m; i++)
  47.                 Console.Write("{0} ", d[i]);
  48.             Console.WriteLine();
  49.  
  50.             // RUSSIAN SORTING HALVES DANILIN
  51.             var start = DateTime.Now;
  52.             if (age > 0)
  53.                 dav(1, n, 1, age);
  54.             var finish = DateTime.Now;
  55.  
  56.             Console.WriteLine("{0} second", (finish - start).TotalSeconds);
  57.  
  58.             // WRITE ON SCREEN
  59.             Console.WriteLine("[1..{0}]", m);
  60.             for (int i = 1; i <= m; i++)
  61.                 Console.Write("{0} ", d[i]);
  62.             Console.WriteLine();
  63.  
  64.             // WRITE ON SCREEN
  65.             Console.WriteLine("[{0}..{1}]", n - m + 1, n);
  66.             for (int i = n - m + 1; i <= n; i++)
  67.                 Console.Write("{0} ", d[i]);
  68.             Console.WriteLine();
  69.  
  70.             // WRITE IN FILE
  71.             var outFile = new StreamWriter("dav.txt");
  72.             for (int i = 1; i <= m; i++)
  73.                 outFile.WriteLine(d[i]);
  74.             outFile.WriteLine();
  75.  
  76.             for (int i = n - m + 1; i <= n; i++)
  77.                 outFile.WriteLine(d[i]);
  78.             outFile.WriteLine();
  79.             outFile.Close();
  80.  
  81.             Console.WriteLine("Press any key");
  82.             Console.ReadKey();
  83.         }
  84.  
  85.         static void dav(int ab, int yz, int part, double age)
  86.         {
  87.             if (yz - ab < 1)
  88.                 return;
  89.  
  90.             long summa = 0;
  91.             for (int i = ab; i <= yz; i++)
  92.                 summa = summa + d[i];
  93.  
  94.             double middle = summa / (yz - ab + 1.0);
  95.  
  96.             var abc = ab - 1;
  97.             var xyz = yz + 1;
  98.  
  99.             for (int i = ab; i <= yz; i++)
  100.                 if (d[i] < middle)
  101.                 {
  102.                     abc = abc + 1;
  103.                     a[abc] = d[i];
  104.                 }
  105.                 else
  106.                 {
  107.                     xyz = xyz - 1;
  108.                     a[xyz] = d[i];
  109.                 }
  110.  
  111.             for (int i = ab; i <= yz; i++)
  112.                 d[i] = a[i];
  113.  
  114.             if (part < age)
  115.             {
  116.                 if (abc >= ab) dav(ab, abc, part + 1, age);
  117.                 if (xyz <= yz) dav(xyz, yz, part + 1, age);
  118.             }
  119.             return;
  120.         }
  121.     }
  122. }
Russian Sorting Halves and fast and human
sorts 1'000'000 in 2.2 seconds on QB64
sorts 1'000'000 in 0.3 seconds on PureBasic
sorts 1'000'000 in 0.2 seconds on C# Csharp
sorts 1'000'000 in 0.15 seconds on Freebasic
Oct 30 '18 #1
7 2867
DANILIN
24 16bit
Russian Sorting Halves Danilin visualisation

https://www.youtube.com/watch?v=UxvSwOtpiuc
https://www.youtube.com/watch?v=9poxfAcbxFQ

Oct 30 '18 #2
DANILIN
24 16bit
a 4 times acceleration proof

Expand|Select|Wrap|Line Numbers
  1. // Russian Sorting Halves 4 part accelerate bubble sorting 
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7. namespace octoberApp
  8. {
  9.     class Program
  10.     {
  11.         static int n;
  12.         static double[] d;
  13.         static double[] a;
  14.         static double[] v;
  15.         static int[] q;
  16.  
  17.         static void Main(string[] args)
  18.         {
  19.             n = 57539; 
  20.  
  21.             d = new double[n+1];
  22.             a = new double[n+1];
  23.             v = new double[n+1];
  24.             q = new int[5+1];
  25.             var rand = new Random();
  26.             for (int i = 1; i <= n; i++)
  27.                 d[i] = Math.Truncate(rand.NextDouble() * n);
  28.  
  29.             for (int i = 1; i <= 10; i++)
  30.                 Console.Write("{0} ", d[i]);
  31.             Console.WriteLine();
  32.  
  33.             for (int i = n - 9; i <= n; i++)
  34.                 Console.Write("{0} ", d[i]);
  35.             Console.WriteLine();
  36.             Console.WriteLine();
  37.  
  38.             var start = DateTime.Now;
  39.             var s = 0;
  40.             //ALL
  41.             double summa = 0;
  42.             for (int i = 1; i <= n; i++)
  43.                 summa += d[i];
  44.             double middle = summa / n;
  45.             var y = 1;
  46.             var z = 0;
  47.  
  48.             for (int i = 1; i <= n; i++)
  49.                 if (d[i] < middle)
  50.                 {
  51.                     a[y] = d[i]; y++;
  52.                 }
  53.                 else
  54.                 {
  55.                     a[n - z] = d[i];
  56.                     z++;
  57.                 }
  58.  
  59.             q[3] = y - 1;
  60.             Console.WriteLine("ALL middle = {0}", middle);
  61.  
  62.             for (int i = 1; i <= 10; i++)
  63.                 Console.Write("{0} ", a[i]);
  64.             Console.WriteLine();
  65.             Console.WriteLine();
  66.             for (int i = n - 9; i <= n; i++)
  67.                 Console.Write("{0} ", a[i]);
  68.             Console.WriteLine();
  69.             Console.WriteLine();
  70.  
  71.             // 1 FROM 2
  72.             summa = 0;
  73.             for (int i = 1; i <= q[3]; i++)
  74.                 summa += a[i];
  75.  
  76.             middle = summa / q[3];
  77.             y = 1;
  78.             z = 0;
  79.             Console.WriteLine("1 FROM 2 = {0} 1 ...{1}", middle, q[3]);
  80.  
  81.             for (int i = 1; i <= q[3]; i++)
  82.                 if (a[i] < middle)
  83.                 {
  84.                     v[y] = a[i]; y++;
  85.                 }
  86.                 else
  87.                 {
  88.                     v[q[3] - z] = a[i];
  89.                     z++;
  90.                 }
  91.  
  92.             for (int i = 1; i <= 10; i++)
  93.                 Console.Write("{0} ", v[i]);
  94.             Console.WriteLine();
  95.             for (int i = q[3] - 9; i <= q[3]; i++)
  96.                 Console.Write("{0} ", v[i]);
  97.             Console.WriteLine();
  98.             Console.WriteLine();
  99.  
  100.             q[2] = y - 1;
  101.  
  102.             // 2 FROM 2
  103.             summa = 0;
  104.             for (int i = q[3] + 1; i <= n; i++)
  105.                 summa += a[i];
  106.             middle = summa / (1 + n - q[3]);
  107.             y = q[3];
  108.             z = 0;
  109.             Console.WriteLine("2 FROM 2 = {0} {1}...{2}", middle, q[3] + 1, n);
  110.             for (int i = q[3]; i <= n; i++)
  111.                 if (a[i] < middle)
  112.                 {
  113.                     v[y] = a[i]; y++;
  114.                 }
  115.                 else
  116.                 {
  117.                     v[n - z] = a[i];
  118.                     z++;
  119.                 }
  120.             for (int i = q[3]; i <= q[3] + 10; i++)
  121.                 Console.Write("{0} ", v[i]);
  122.             Console.WriteLine();
  123.             for (int i = n - 9; i <= n; i++)
  124.                 Console.Write("{0} ", v[i]);
  125.             Console.WriteLine();
  126.             Console.WriteLine();
  127.  
  128.             q[4] = y - 1;
  129.             q[1] = 2;
  130.             q[5] = n;
  131.  
  132.             //BUBBLE
  133.             Console.WriteLine("1= {0} 2= {1} 3= {2} 4= {3} 5= {4}", 1, q[2], q[3], q[4], n);
  134.             Console.WriteLine();
  135.  
  136.             for (int t = 1; t <= 4; t++)
  137.                 for (int i = q[t] - 1; i <= q[t + 1]; i++)
  138.                     for (int j = i + 1; j <= q[t + 1]; j++)
  139.                         if (v[i] > v[j])
  140.                         {
  141.                             var x = v[i];
  142.                             v[i] = v[j];
  143.                             v[j] = x;
  144.                             s++;
  145.                         }
  146.  
  147.             var finish = DateTime.Now;
  148.  
  149.             for (int i = 1; i <= 10; i++)
  150.                 Console.Write("{0} ", v[i]);
  151.             Console.WriteLine();
  152.  
  153.             for (int i = n - 9; i <= n; i++)
  154.                 Console.Write("{0} ", v[i]);
  155.             Console.WriteLine();
  156.             Console.WriteLine();
  157.             Console.WriteLine("DA RUS 4 {0} second swap {1}", (finish - start).TotalSeconds, s);
  158.  
  159.  
  160.             var outFile = new System.IO.StreamWriter("RUoct.txt");
  161.             outFile.WriteLine("DA RUS 4 {0} second swap {1}", (finish - start).TotalSeconds, s);
  162.             outFile.WriteLine("{0} 4 parts bubble ", n);
  163.  
  164.             for (int i = 1; i <= n / 2; i++)
  165.                 outFile.WriteLine(v[i]);
  166.             for (int i = n / 2; i <= n; i++)
  167.                 outFile.WriteLine(v[i]);
  168.  
  169.             outFile.Close();
  170.  
  171.             start = DateTime.Now;
  172.             s = 0;
  173.  
  174.             for (int i = 1; i <= n; i++)
  175.                 for (int j = i + 1; j <= n; j++)
  176.                     if (d[i] > d[j])
  177.                     {
  178.                         var x = d[i];
  179.                         d[i] = d[j];
  180.                         d[j] = x;
  181.                         s++;
  182.                     }
  183.             finish = DateTime.Now;
  184.  
  185.             Console.WriteLine("BUBBLE {0} second swap {1}", (finish - start).TotalSeconds, s);
  186.  
  187.             Console.WriteLine("Press any key");
  188.             Console.ReadKey();
  189.         }
  190.     }
  191. }
a 4 times acceleration proof





division of array into 4 parts occurs instantly
name q(3) will be replaced by a simpler name

but separation attempts for 2 nested loops
broken about order of midpoints 3 2 4

which leads to arrays with 2nd brackets
which complicates understanding and better apply

speaking variables of type middle3
leaving 3 cycles separate
Oct 30 '18 #3
DANILIN
24 16bit
We learn C# knowing Basic & Excel & qb64

? Why C# & Basic & Excel & qb64?
because C# & qb64 are compiled

I have a C# csc.exe compiler in Win7
and compile through an individual bat

Excel: even micro-sized environments
Basic: qb64 compatible with Win7

qb64 quadratic equation:

Expand|Select|Wrap|Line Numbers
  1. ' quadratic equation QB64 DAV 
  2.  
  3. INPUT "INPUT A"; A
  4. INPUT "INPUT B"; B
  5. INPUT "INPUT C"; C
  6.  
  7. D = B ^ 2 - 4 * A * C
  8.  
  9. IF D < 0 THEN PRINT "D<0 ": END
  10.  
  11. PRINT "ANSWER: "
  12. PRINT "D ="; D
  13.  
  14. X1 = (-B + SQR(D)) / (2 * A)
  15. X2 = (-B - SQR(D)) / (2 * A)
  16.  
  17. PRINT "X1 ="; X1
  18. PRINT "X2 ="; X2
  19.  
  20. END
C# quadratic equation without checking d<0:

Expand|Select|Wrap|Line Numbers
  1. // quadratic equation C# DAV  
  2. using System;
  3. using System.Text;
  4. using System.IO;
  5. namespace DAV 
  6. {
  7.     class Program
  8.         {
  9.     static void Main(string[] args)
  10.     {
  11. Console.Write("INPUT A: ");
  12. long a = Convert.ToInt32(Console.ReadLine());
  13. Console.Write("INPUT B: ");
  14. long b = Convert.ToInt32(Console.ReadLine());
  15. Console.Write("INPUT C: ");
  16. long c = Convert.ToInt32(Console.ReadLine());
  17.  
  18. long d = (b * b - 4 * a * c);
  19. Console.WriteLine("ANSWER: ");
  20. Console.Write("D = "); 
  21. Console.WriteLine(d);
  22.  
  23. var x1 = (-b + Math.Sqrt(d)) / (2 * a);
  24. var x2 = (-b - Math.Sqrt(d)) / (2 * a);
  25.  
  26. Console.Write("X1 = "); 
  27. Console.WriteLine(x1);
  28. Console.Write("X2 = "); 
  29. Console.WriteLine(x2);
  30.  
  31.         Console.ReadKey();
  32.         }
  33.     }
  34. }
excel quadratic equation without checking d<0:
excel: copy and paste in A1

Expand|Select|Wrap|Line Numbers
  1. 6
  2. 7
  3. 2
  4. =A2^2-4*A1*A3
  5. =(-A2+(A4^(1/2)))/(2*A1)
  6. =(-A2-(A4^(1/2)))/(2*A1)
further need to examine conditions
creating a toy "guess number"
Mar 22 '19 #4
DANILIN
24 16bit
qb64 for 1 minute created main lines and for minutes issued
C# in 3 hours created by internet tips with new ideas

Expand|Select|Wrap|Line Numbers
  1. 'qb64 dav guess number from 0 to 100 with counting of steps 
  2. RANDOMIZE TIMER
  3. s = INT(RND * 100)
  4. t = 0
  5.  
  6. 10 PRINT: t = t + 1:
  7. INPUT "your variant"; a
  8.  
  9. IF a < s THEN PRINT "need MORE": GOTO 10
  10. IF a > s THEN PRINT "need less": GOTO 10
  11. PRINT "win by"; t; "steps"
  12. END
Expand|Select|Wrap|Line Numbers
  1. '//C# dav guess number from 0 to 100 with counting of steps 
  2. using System;
  3. using System.Text;
  4. namespace DAV 
  5. {
  6.     class Program
  7.         {
  8.     static void Main(string[] args) 
  9.     {
  10. Random rand = new Random();
  11. int s = rand.Next(100);
  12. int t = 0;
  13.  
  14. dav:
  15. Console.WriteLine();
  16. t++;
  17.  
  18. Console.Write("your variant ");
  19. string d = Console.ReadLine();
  20. int a = Convert.ToInt32(d);
  21.  
  22. if(a > s)
  23.     {
  24.     Console.WriteLine("need less");
  25.     goto dav;
  26.     }
  27. else if(a < s)
  28.     {
  29.     Console.WriteLine("need MORE");
  30.     goto dav;
  31.     }
  32. Console.Write("win by ");
  33. Console.Write(t);
  34. Console.Write(" steps"); 
  35.         Console.ReadKey();
  36.         }
  37.     }
  38. }
Mar 22 '19 #5
DANILIN
24 16bit
Expand|Select|Wrap|Line Numbers
  1. 'milliard & billion qb64 DAV guess 1 number of 1'OOO'000'ooo by 30 steps
  2.  
  3. RANDOMIZE TIMER
  4. h2 = INT(RND * 10 ^ 9)
  5. h1 = 0
  6. c = INT(RND * h2) 'comp
  7. h = INT(RND * h2) 'human
  8. t = 0
  9.  
  10. 10 t = t + 1
  11. PRINT t, c, h,
  12.  
  13. IF h < c THEN PRINT "MORE": a = h: h = INT((h + h2) / 2): h1 = a: GOTO 10
  14. IF h > c THEN PRINT "less": a = h: h = INT((h1 + h) / 2): h2 = a: GOTO 10
  15. PRINT "win by "; t; " steps"
  16. END
C# compiler feature noticed
remark that there is a mistake at beginning of program
may mean a lack of characters } at end

example for a range from 0 to 100
Expand|Select|Wrap|Line Numbers
  1. 1    40    11    MORE
  2. 2    40    55    less
  3. 3    40    33    MORE
  4. 4    40    44    less
  5. 5    40    38    MORE
  6. 6    40    41    less
  7. 7    40    39    MORE
  8. 8    40    40    win by 8 steps
BasiC# qbc# C##


Online C# compiler detected
and dozens more languages without qbasic
working without registration

and there typing program is possible
save state with program

for example program C # Billion
guessing 1 of 1'000'OOO'ooo
=log(10^9;2) in 30 moves

rextester.com/JRGX29275

Expand|Select|Wrap|Line Numbers
  1. //milliard & billion C# DAV guess 1 number of 1000000000 by 30 steps  
  2. using System;
  3. using System.Text;
  4. namespace DAV
  5. {
  6.     class Program
  7.     {
  8.     static void Main(string[] args)
  9.     {
  10. int h2 = 1000000000;//or 500
  11. int h1 = 0;
  12. Random rand = new Random();
  13. int c = rand.Next(h2); //computer
  14. int h = rand.Next(h2); //human or h2/2;
  15. int t = 0;
  16.  
  17. dav:
  18. t++;
  19. Console.WriteLine();
  20. Console.Write(t);
  21. Console.Write("  ");
  22. Console.Write(c);
  23. Console.Write("  ");
  24. Console.Write(h);
  25. Console.Write("  ");
  26.  
  27. if(h < c)
  28.     {
  29.     Console.Write("MORE");
  30.     int a = h;
  31.     h = (h + h2) / 2;
  32.     h1 = a;
  33.     goto dav;
  34.     }
  35. else if(h > c)
  36.     {
  37.     Console.Write("less");
  38.     int a = h;
  39.     h = (h1 + h) / 2;
  40.     h2 = a;
  41.     goto dav;
  42.     }
  43. Console.Write("win by ");
  44. Console.Write(t);
  45. Console.Write(" steps");
  46.         Console.ReadKey();
  47.         }
  48.     }
  49. }

Searching see programs stored ... 5 years
and for certain still there is an online compiler C#
and really are through Yandex search

but since interested in graphics
while I use cs & bat
Mar 28 '19 #6
DANILIN
24 16bit
we draw 5D relief creating a random array of heights

on QB64 in 5 minutes and plus in an hour
beauty and versatility

[IMG]reliefqb.gif[/IMG]

Expand|Select|Wrap|Line Numbers
  1. ' 5d relief and array
  2. SCREEN 12: RANDOMIZE TIMER: DIM a(12,12)
  3. FOR t=1 TO 12 ' quantity
  4.     FOR x=1 TO 12: FOR y=1 TO 12
  5. a(x,y)=INT(RND*20)'heights
  6.     NEXT: NEXT: CLS
  7.     FOR y=1 TO 12: FOR x=1 TO 11
  8. LINE (50+20*x+20*y, 400-20*y-a(x,y))-(50+20*(x+1)+20*y, 400-20*y-a(x+1,y)), y
  9.     NEXT: NEXT
  10.     FOR x=1 TO 12: FOR y=1 TO 11
  11. LINE (50+20*x+20*y, 400-20*y-a(x,y))-(50+20*(x+1)+20*y, 400-20*(y+1)-a(x,y+1)), x
  12.     NEXT: NEXT:SLEEP 1
  13. NEXT
  14. END
on C# pendulum program is used
because of what remained incomprehensible lines about timer
and random function depends on outside / inside cycles
and to understand another program created random

how to clear screen is still unclear and builds slowly
and it is unclear how to set color of lines by variables

[IMG]reliefcs.gif[/IMG]

still as task manager shows
simple C# program or array fills memory
and only at end does memory clear line save

Expand|Select|Wrap|Line Numbers
  1. //RELIEF
  2. using System;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. class RELIEF
  6. {
  7. Timer timer; // it is not clear
  8. Form form;
  9.  
  10. int[,] a = new int[22, 22];
  11. static void Main(string[] args) 
  12. {
  13. var p = new RELIEF();
  14. }
  15. public RELIEF()
  16. {
  17.     form = new Form() { Text = "RELIEF", Width = 600, Height = 360 };
  18.     timer = new Timer() { Interval = 200 }; // it is not clear
  19.     timer.Tick += delegate(object sender, EventArgs e) // it is not clear
  20.     {
  21.     Random rand = new Random();
  22. // heights
  23.     for (int x = 1; x <=12; x++)
  24.     {
  25.     for (int y = 1; y <=12; y++)
  26.     a[x,y]=rand.Next(20);
  27.     }
  28. // parallels X
  29.     for (int y = 1; y <=12; y++)
  30.     {
  31.     for (int x = 1; x <=11; x++)
  32.         {
  33.     var x1 = 50 + 20*x + 20*y; 
  34.     var y1 = 300 - 20*y - a[x,y];
  35.     var x2 = 50 + 20*(x+1) + 20*y;
  36.     var y2 = 300 - 20*y - a[x+1,y];
  37.  
  38.     Bitmap dblBuffer = new Bitmap(form.Width, form.Height);
  39.     Graphics g = Graphics.FromImage(dblBuffer);
  40.     Graphics f = Graphics.FromHwnd(form.Handle);
  41.  
  42.     g.DrawLine(Pens.Red, new Point(x1, y1), new Point(x2, y2));
  43. //    f.Clear(Color.Green); // clear screen
  44.     f.DrawImage(dblBuffer, new Point(0, 0));
  45.      }
  46.     }
  47. // parallels Y
  48.     for (int x = 1; x <=12; x++)
  49.     {
  50.     for (int y = 1; y <=11; y++)
  51.     {
  52.     var x1 = 50 + 20*x + 20*y; 
  53.     var y1 = 300 - 20*y - a[x, y];
  54.     var x2 = 50 + 20*(x+1) + 20*y;
  55.     var y2 = 300 - 20*(y+1) - a[x, y+1];
  56.  
  57.     Bitmap dblBuffer = new Bitmap(form.Width, form.Height);
  58.     Graphics g = Graphics.FromImage(dblBuffer);
  59.     Graphics f = Graphics.FromHwnd(form.Handle);
  60.  
  61.     g.DrawLine(Pens.Red, new Point(x1, y1), new Point(x2, y2));
  62. //    f.Clear(Color.Green); // clear screen
  63.     f.DrawImage(dblBuffer, new Point(0, 0));
  64.     }
  65.     }
  66. Array.Clear(a, 0, 22); // clears memory
  67.     };
  68.     timer.Start(); // it is not clear
  69.     Application.Run(form);
  70.     }     
  71. }
besides C# pendulum is C # diagonal simpler
and no other C# program is included
so as in basic: 1 file = 1 program

that's why my given 5D relief program is important.
drawing at least something predictable
and at same time we study nested loops

and I'm still looking for compilable graphics programs:

1 file = 1 program
1bas=1exe & 1cs=1exe

and already created studies about strings
Mar 29 '19 #7
DANILIN
24 16bit
c# version of "guess my number game" 1 line
Expand|Select|Wrap|Line Numbers
  1. using System; using System.Text;namespace GURU { class Program { static void Main(string[] args) { Random rand = new Random(); int Russia = 0; int n = 0; int num = 0; dav: if(Russia == 0) {Russia = 2222; num = rand.Next(100)+1; goto dav; }else if (Russia != 0) {Console.Write("? "); n = Convert.ToInt32(Console.ReadLine());} if (n < num) { Console.WriteLine("MORE"); goto dav;}else if (n > num) { Console.WriteLine("less"); goto dav;}else if (n == num) {Console.Write("da"); Console.ReadKey(); }else goto dav;}}}// DANILIN Russia 9-9-2019 guessnum.cs
using System; using System.Text;namespace GURU { class Program { static void Main(string[] args) { Random rand = new Random(); int Russia = 0; int n = 0; int num = 0; dav: if(Russia == 0) {Russia = 2222; num = rand.Next(100)+1; goto dav; }else if (Russia != 0) {Console.Write("? "); n = Convert.ToInt32(Console.ReadLine());} if (n < num) { Console.WriteLine("MORE"); goto dav;}else if (n > num) { Console.WriteLine("less"); goto dav;}else if (n == num) {Console.Write("da"); Console.ReadKey(); }else goto dav;}}}// DANILIN Russia 9-9-2019 guessnum.cs

c# version of "guess my number game" 1 line

qbasic version of "guess my number game" 1 line
Expand|Select|Wrap|Line Numbers
  1. 1 IF Russia = 0 THEN Russia = 2222: RANDOMIZE TIMER: num = INT(RND * 100) + 1: GOTO 1 ELSE IF Russia <> 0 THEN INPUT n: IF n < num THEN PRINT "MORE": GOTO 1 ELSE IF n > num THEN PRINT "less": GOTO 1 ELSE IF n = num THEN PRINT "da": END ELSE GOTO 1 'DANILIN Russia 9-9-2019 guessnum.bas
1 IF Russia = 0 THEN Russia = 2222: RANDOMIZE TIMER: num = INT(RND * 100) + 1: GOTO 1 ELSE IF Russia <> 0 THEN INPUT n: IF n < num THEN PRINT "MORE": GOTO 1 ELSE IF n > num THEN PRINT "less": GOTO 1 ELSE IF n = num THEN PRINT "da": END ELSE GOTO 1 'DANILIN Russia 9-9-2019 guessnum.bas

qbasic version of "guess my number game" 1 line
Sep 12 '19 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: M. Posseth | last post by:
hello ,, does someone know how i can acomplish the folowing task ,, i have a program with a HTML interface and i need to write Russian chars to the generated HTML files my database is...
5
by: Steven | last post by:
Hi all, I would like to create a site which shows text in English or in Russian (depending on the user's choice). Problem is that I can't save the pages in Unicode (Unicode can contain Russian...
5
by: Wahoo | last post by:
Dear All, What is the name of sorting algorithm used in list (STL) class? and how it work? Thanks!!! Best Regards, Wahoo
2
by: Ross Noe via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Ross Noe I created an XML file using ASP that has Russian characters. Forsome reason ASP.Net doesn't read the Russian...
3
by: Roger Withnell | last post by:
I am using ASP, VBScript and MSSQL Server. I do not understand the purpose of the VBS Codepage setting - <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> nor the meta tag - <meta...
6
by: Victor | last post by:
Hi everybody, could anybody help me with the following problem : I need to set a cookie containing a Russian character string as the value, using the construct "document.cookie = ...". The...
9
by: Roger Withnell | last post by:
I've built a site in English and an now translating it into Russian. My html charset= utf-8 and my vbscript codepage is 65001. I'm using DreamWeaver. If there is a Javascript function in a...
5
by: Hank Moss | last post by:
I've been able to get the <qelement and the CSS quotes property to work well together in English, but not in Russian or mixed Russian and English. I probably don't have a firm enough grasp of the...
26
by: mike-yue | last post by:
The topic comes from a question: Would you rather wait for the results of a quicksort, a linear search, or a bubble sort on a 200000 element array? 1Quicksort 2Linear Search 3Bubble Sort ...
2
by: frenzy99 | last post by:
Can someone suggest a way to Sort two halves of DataGridView (based on the same column/criteria) and then merge the two sorted halves. say the datagrid view has 10 rows (with name/string) 1.D...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.