Advertisement
Guest User

Untitled

a guest
Feb 15th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Welcome to GDB Online.
  4. GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
  5. C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
  6. Code, Compile, Run and Debug online from anywhere in world.
  7.  
  8. *******************************************************************************/
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14.  
  15. namespace ConsoleApplication4
  16. {
  17.  
  18.  
  19. class Program
  20. {
  21. static void printmas(int[] a)
  22. {
  23. for(int i=0;i< a.Length;i++)
  24. Console.Write(a[i]+" ");
  25. return;
  26. }
  27.  
  28. static void randmas(int[] a)
  29. {
  30. Random rnd =new Random();
  31. for(int b=0;b<a.Length;b++)
  32. a[b]=rnd.Next(10);
  33. return ;
  34. }
  35.  
  36. static void sort(int[] a)
  37. {
  38. int min;
  39. for (int i = 0; i < a.Length-1; i++)
  40. {
  41. for (int j = i + 1; j < a.Length; j++)
  42. {
  43. if (a[i] > a[j])
  44. {
  45. min = a[i];
  46. a[i] = a[j];
  47. a[j] = min;
  48. }
  49. }
  50. }
  51. return ;
  52. }
  53.  
  54. static void Main(string[] args)
  55. {
  56. int[] a= new int[5];
  57. randmas(a);
  58. printmas(a);
  59. sort(a);
  60. Console.WriteLine();
  61. printmas(a);
  62. Console.ReadKey();
  63. }
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement