Răsfoiți Sursa

new file c++/l6.cpp for an easy math exam with 3 examples

root 1 lună în urmă
părinte
comite
e463d31f71
1 a modificat fișierele cu 43 adăugiri și 0 ștergeri
  1. 43 0
      c++/l6.cpp

+ 43 - 0
c++/l6.cpp

@@ -0,0 +1,43 @@
+#include <iostream>
+#include <random>
+#include <string>
+
+int all() {
+	std::random_device rd;
+	std::mt19937 gen(rd());
+	std::uniform_int_distribution<int> distrib(1, 100);
+	int i = 0;
+	while(i <= 3) {
+		int x1 = distrib(gen);
+		int x2 = distrib(gen);
+		int x3 = x1+x2;
+		int pol;
+		std::cout << x1 << "+" << x2 << "=?" << std::endl;
+		std::cin >> pol;
+		if(pol == x3) {
+			std::cout << "Верно!" << std::endl;
+			std::cout << x1 << "+" << x2 << "=" << x3 << std::endl;
+		}
+		else {
+			std::cout << "Не верно!" << std::endl;
+			std::cout << x1 << "+" << x2 << "=" << x3 << std::endl;
+			return 0;
+		}
+	}
+	return 1;
+}
+
+int main() {
+	while(1) {
+		std::string polz;
+		std::cout << "1. Начать\n2. Закончить" << std::endl;
+		std::cin >> polz;
+		if(polz == "1") {
+			all();
+		}
+		else if(polz == "2") {
+			return 0;
+		}
+	}
+	return 0;
+}