Advertisement
AleksandarH

Niki - 2 Zad.

Dec 15th, 2022
682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11.  
  12. namespace test2._2
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.        
  17.  
  18.         public Form1()
  19.         {
  20.            
  21.             InitializeComponent();
  22.  
  23.         }
  24.  
  25.         private void button1_Click(object sender, EventArgs e)
  26.         {
  27.             Random rnd = new Random();
  28.             List<int> c = new List<int>();
  29.             List<int> v = new List<int>();
  30.             List<int> b = new List<int>();
  31.  
  32.             for (int j = 0; j < 10; j++)
  33.             {
  34.                 c.Add(rnd.Next(-10, 15));
  35.                 if (c[j] < 0 && c[j] > -10)
  36.                 {
  37.                     v.Add(c[j]);
  38.                 }
  39.                 else if (c[j] > 0 && c[j] >= 10)
  40.                 {
  41.                     b.Add(c[j]);
  42.                 }
  43.  
  44.             }
  45.             c.Sort();
  46.             listBox1.DataSource = c;
  47.             listBox2.DataSource = v;
  48.             listBox3.DataSource = b;
  49.             String a = string.Join(",", c) +"\n "+ string.Join(",", b) +"\n "+ string.Join(",",v);
  50.             StreamWriter s = new StreamWriter(@"Rezultat.txt");
  51.                 s.Write(a);
  52.                 s.Close();
  53.            
  54.         }
  55.  
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement