Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 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.  
  11. namespace quizmaster
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20. Random r = new Random();
  21. int ra, choice, right;
  22.  
  23. private void button1_Click(object sender, EventArgs e)
  24. {
  25. int counter = 0;
  26. right = 0;
  27. choice = 1;
  28.  
  29. while (counter != 100)
  30. {
  31. ra = r.Next(1, 4);
  32. if (ra == choice)
  33. {
  34. right++;
  35. }
  36. counter++;
  37. }
  38. MessageBox.Show(right.ToString());
  39.  
  40. }
  41.  
  42. private void button2_Click(object sender, EventArgs e)
  43. {
  44. int counter = 0;
  45. int od = 1;
  46. right = 0;
  47. choice = 1;
  48. while (counter != 100)
  49. {
  50. ra = r.Next(1, 4);
  51. while (od == choice || od == ra)
  52. {
  53. od++;
  54. }
  55.  
  56. while (choice == 1 || choice == od)
  57. {
  58. choice++;
  59. }
  60. if (choice == ra)
  61. {
  62. right++;
  63. }
  64. counter++;
  65. od = 1;
  66. choice = 1;
  67. }
  68. MessageBox.Show(right.ToString());
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement