Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit83372bc2f825327fa194e6ea71259b1f54234e6d (patch)
Author
 Stoycho Kyosev <68247567+stoychoX@users.noreply.github.com>
2021-11-03 00:45:27 +0200
Committer
 GitHub <noreply@github.com>
2021-11-03 00:45:27 +0200
Files7da33d488e97bddabd3b9077613e39c494bbbccd
Introduction_to_programming_FMI-83372bc2f825327fa194e6ea71259b1f54234e6d.tar
Introduction_to_programming_FMI-83372bc2f825327fa194e6ea71259b1f54234e6d.tar.gz
Introduction_to_programming_FMI-83372bc2f825327fa194e6ea71259b1f54234e6d.zip
Parent360b182835727a43d426f5df2de3184cb91ca035 (diff)
Add files via upload
1 files changed, 64 insertions, 0 deletions
-rw-r--r--pract_KN/pract. 04/solutions/solutions.cpp64
diff --git a/pract_KN/pract. 04/solutions/solutions.cpp b/pract_KN/pract. 04/solutions/solutions.cpp
new file mode 100644
index 0000000..7a1df9f
--- /dev/null
+++ b/pract_KN/pract. 04/solutions/solutions.cpp
@@ -0,0 +1,64 @@
+#include<iostream>
+
+int sumInInterval(int n, int m) {
+ int result = 0;
+ for (int i = n; i <= m; i++)
+ result += i;
+
+ return result;
+}
+
+double power(double number, int n) {
+ double result = 1;
+ for (int i = 0; i < n; i++)
+ result *= n;
+ return result;
+}
+
+int absolute(int n) {
+ if (n < 0)
+ return -n;
+ return n;
+}
+
+double dist(double x1, double y1, double x2, double y2) {
+ return sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
+}
+
+double perimeter(double x1, double y1, double x2, double y2, double x3, double y3) {
+ return dist(x1, y1, x2, y2) + dist(x1, y1, x3, y3) + dist(x2, y2, x3, y3);
+}
+
+int fact(int n) {
+ int result = 1;
+ for (int i = 1; i <= n; i++)
+ result *= i;
+ return result;
+}
+
+bool isNumber(char n) {
+ return (n >= '0' && n <= '9');
+}
+
+//Защо това работи?
+int f(int a, int b) {
+ return (a + b) * (a + b + 1) / 2 + b;
+}
+
+void play() {
+ int computerNumber = rand() % 100 + 1;
+ int myNumber = 0;
+ while (myNumber != computerNumber) {
+ std::cout << "Enter a number -> ";
+ std::cin >> myNumber;
+ if (myNumber > computerNumber)
+ std::cout << "Try smaller number" << std::endl;
+ else if (myNumber < computerNumber)
+ std::cout << "Try bigger number" << std::endl;
+ }
+ std::cout << "Rigth!!!" << std::endl;
+}
+
+int main() {
+ //(...)
+} \ No newline at end of file