Advertisement
kr0n4ik

Untitled

Jun 21st, 2021
1,290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15.  
  16. namespace test
  17. {
  18.     /// <summary>
  19.     /// Логика взаимодействия для MainWindow.xaml
  20.     /// </summary>
  21.     public partial class MainWindow : Window
  22.     {
  23.         public class A
  24.         {
  25.             public int b = 0;
  26.  
  27.             public A()
  28.             {
  29.                 this.b = 0;
  30.             }
  31.  
  32.             public A(int b)
  33.             {
  34.                 this.b = b;
  35.             }
  36.         }
  37.  
  38.         private A tmp = new A();
  39.         private List<A> ass = new List<A>();
  40.         private A pos = new A();
  41.         public MainWindow()
  42.         {
  43.             InitializeComponent();
  44.             pos.b = 5;
  45.         }
  46.  
  47.         public A func(A b, A a)
  48.         {
  49.             return (b.b < 4) ? a : new A(-a.b);
  50.         }
  51.  
  52.         private void print_ass()
  53.         {
  54.             String text = "";
  55.             foreach (A a in ass)
  56.                 text += a.b + " | ";
  57.             L1.Content = text;
  58.         }
  59.  
  60.         //Лесенка в ass должно лежать  1 2 3 4 -3 -2 -1 0
  61.         private void Button_Click(object sender, RoutedEventArgs e)
  62.         {
  63.  
  64.             A last = new A(tmp.b);
  65.             tmp = func(last, tmp);
  66.             tmp.b += 1;
  67.             ass.Add(tmp);
  68.  
  69.             print_ass();
  70.         }
  71.  
  72.         //Замена последнего значения
  73.         private void Button_Click_1(object sender, RoutedEventArgs e)
  74.         {
  75.             tmp = func(pos, tmp);
  76.             print_ass();
  77.         }
  78.     }
  79. }
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement