fork download
  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.Windows.Forms;
  9.  
  10. namespace WindowsFormsApplication14
  11. {
  12. public partial class Form1 : Form
  13. {
  14. private Random rand = new Random();
  15. private int[] x = new int[4];
  16. private string s;
  17. private int polnoeSovpadenie;
  18. private int chastichnoeSovpadenie;
  19.  
  20. public Form1()
  21. {
  22. InitializeComponent();
  23. NewGame();
  24. }
  25.  
  26. private void NewGame()
  27. {
  28. NovoeChislo();
  29. label2.Text = "";
  30. label3.Text = "";
  31. textBox1.ReadOnly = false;
  32. }
  33.  
  34. private void NovoeChislo()
  35. {
  36. bool contains;
  37. for (int i = 0; i < 4; i++)
  38. {
  39. do
  40. {
  41. contains = false;
  42. x[i] = rand.Next(10);
  43. for (int k = 0; k < i; k++)
  44. if (x[k] == x[i])
  45. contains = true;
  46. } while (contains);
  47. }
  48. s = x[0].ToString() + x[1] + x[2] + x[3];
  49. }
  50.  
  51. private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  52. {
  53. if (Char.IsDigit(e.KeyChar) || e.KeyChar == (char)Keys.Back)
  54. e.Handled = false;
  55. else
  56. e.Handled = true;
  57. }
  58.  
  59. private void button1_Click(object sender, EventArgs e)
  60. {
  61. if (textBox1.Text.Length != 4)
  62. {
  63. MessageBox.Show("введенное число должно быть четырехзначным");
  64. }
  65. else
  66. {
  67. SravenieChisel();
  68. RezultShow();
  69. }
  70. textBox1.Text = "";
  71. }
  72.  
  73. private void RezultShow()
  74. {
  75. label2.Text += textBox1.Text + " полностью совпало " + polnoeSovpadenie + " совпало " + chastichnoeSovpadenie + "\n";
  76. }
  77.  
  78. private void SravenieChisel()
  79. {
  80. polnoeSovpadenie = 0;
  81. chastichnoeSovpadenie = 0;
  82. char[] ch = textBox1.Text.ToCharArray();
  83. for (int i = 0; i < 4; i++)
  84. {
  85. if (s.Contains(ch[i]))
  86. {
  87. if (s[i] == ch[i])
  88. polnoeSovpadenie++;
  89. else
  90. chastichnoeSovpadenie++;
  91. }
  92. }
  93. }
  94.  
  95. private void button2_Click(object sender, EventArgs e)
  96. {
  97. label3.Text = s;
  98. label2.Text = "";
  99. textBox1.ReadOnly = true;
  100. }
  101.  
  102. private void button3_Click(object sender, EventArgs e)
  103. {
  104. NewGame();
  105. }
  106. }
  107. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:7: error: expected nested-name-specifier before ‘System’
 using System;
       ^
prog.cpp:1:7: error: ‘System’ has not been declared
prog.cpp:2:7: error: expected nested-name-specifier before ‘System’
 using System.Collections.Generic;
       ^
prog.cpp:2:7: error: ‘System’ has not been declared
prog.cpp:2:13: error: expected ‘;’ before ‘.’ token
 using System.Collections.Generic;
             ^
prog.cpp:2:13: error: expected unqualified-id before ‘.’ token
prog.cpp:3:7: error: expected nested-name-specifier before ‘System’
 using System.ComponentModel;
       ^
prog.cpp:3:7: error: ‘System’ has not been declared
prog.cpp:3:13: error: expected ‘;’ before ‘.’ token
 using System.ComponentModel;
             ^
prog.cpp:3:13: error: expected unqualified-id before ‘.’ token
prog.cpp:4:7: error: expected nested-name-specifier before ‘System’
 using System.Data;
       ^
prog.cpp:4:7: error: ‘System’ has not been declared
prog.cpp:4:13: error: expected ‘;’ before ‘.’ token
 using System.Data;
             ^
prog.cpp:4:13: error: expected unqualified-id before ‘.’ token
prog.cpp:5:7: error: expected nested-name-specifier before ‘System’
 using System.Drawing;
       ^
prog.cpp:5:7: error: ‘System’ has not been declared
prog.cpp:5:13: error: expected ‘;’ before ‘.’ token
 using System.Drawing;
             ^
prog.cpp:5:13: error: expected unqualified-id before ‘.’ token
prog.cpp:6:7: error: expected nested-name-specifier before ‘System’
 using System.Linq;
       ^
prog.cpp:6:7: error: ‘System’ has not been declared
prog.cpp:6:13: error: expected ‘;’ before ‘.’ token
 using System.Linq;
             ^
prog.cpp:6:13: error: expected unqualified-id before ‘.’ token
prog.cpp:7:7: error: expected nested-name-specifier before ‘System’
 using System.Text;
       ^
prog.cpp:7:7: error: ‘System’ has not been declared
prog.cpp:7:13: error: expected ‘;’ before ‘.’ token
 using System.Text;
             ^
prog.cpp:7:13: error: expected unqualified-id before ‘.’ token
prog.cpp:8:7: error: expected nested-name-specifier before ‘System’
 using System.Windows.Forms;
       ^
prog.cpp:8:7: error: ‘System’ has not been declared
prog.cpp:8:13: error: expected ‘;’ before ‘.’ token
 using System.Windows.Forms;
             ^
prog.cpp:8:13: error: expected unqualified-id before ‘.’ token
prog.cpp:12:5: error: expected unqualified-id before ‘public’
     public partial class Form1 : Form
     ^
prog.cpp:107:1: error: expected ‘}’ at end of input
 }
 ^
stdout
Standard output is empty