Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- amespace son1
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- private static int[] trio(int n)
- {
- int[] a = new int[3];
- a[1] = n / 3;
- a[0] = a[1] - 1;
- a[2] = a[1] + 1;
- if(n%3==1) {a[2]++;}
- if (n % 3 == 2)
- {
- a[1]++;
- a[2]+=2;
- }
- return a;
- }
- private void go_Click(object sender, RoutedEventArgs e)
- {
- int d = Convert.ToInt32(dan.Text);
- int[] a = trio(d);
- otv.Content = String.Concat("Младнему сыну досталось ", a[0], "м\r\n", "Среднему сыну досталось ", a[1], "м\r\n", "Старшему сыну досталось ", a[2], "м");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement