Advertisement
Guest User

syt

a guest
Mar 4th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. namespace yhteinentekija
  2. {
  3. /// <summary>
  4. /// Interaction logic for MainWindow.xaml
  5. /// </summary>
  6. public partial class MainWindow : Window
  7. {
  8. public MainWindow()
  9. {
  10. InitializeComponent();
  11. }
  12.  
  13. private void nappi_Click(object sender, RoutedEventArgs e)
  14. {
  15. tulos.Text = "A B |A-B|" + "\n";
  16. int a = 0;
  17. int b = 0;
  18.  
  19. string lod1 = lodja1.Text;
  20. string lod2 = lodja2.Text;
  21. if (Int32.TryParse(lod1, out a) == true && Int32.TryParse(lod2, out b) == true)
  22. {
  23. if (a < 0)
  24. {
  25. a = -a;
  26. }
  27.  
  28. if (b < 0)
  29. {
  30. b = -b;
  31. }
  32.  
  33. while (a != b == true)
  34. {
  35. int erotus = 0;
  36. if (a - b < 0)
  37. {
  38. erotus = (b - a);
  39. }
  40. else
  41. {
  42. erotus = (a - b);
  43. }
  44.  
  45. tulos.Text += (a + " " + b + " " + erotus + "\n");
  46. if (a > b == true)
  47. {
  48. a = a - b;
  49.  
  50. }
  51. else
  52. {
  53. b = b - a;
  54. }
  55. }
  56. }
  57. else
  58. {
  59. tulos.Text = "Kirjoita pelkästään luku molempiin kenttiin";
  60. }
  61.  
  62.  
  63. }
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement