Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace yhteinentekija
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- private void nappi_Click(object sender, RoutedEventArgs e)
- {
- tulos.Text = "A B |A-B|" + "\n";
- int a = 0;
- int b = 0;
- string lod1 = lodja1.Text;
- string lod2 = lodja2.Text;
- if (Int32.TryParse(lod1, out a) == true && Int32.TryParse(lod2, out b) == true)
- {
- if (a < 0)
- {
- a = -a;
- }
- if (b < 0)
- {
- b = -b;
- }
- while (a != b == true)
- {
- int erotus = 0;
- if (a - b < 0)
- {
- erotus = (b - a);
- }
- else
- {
- erotus = (a - b);
- }
- tulos.Text += (a + " " + b + " " + erotus + "\n");
- if (a > b == true)
- {
- a = a - b;
- }
- else
- {
- b = b - a;
- }
- }
- }
- else
- {
- tulos.Text = "Kirjoita pelkästään luku molempiin kenttiin";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement