Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Programming introduction / Practice-18.10.21.cpp
diff options
context:
space:
mode:
Commit2ec5faa88be1447cd93a301543f97ac9d6c312d7 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-10-25 13:49:06 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-10-25 13:49:06 +0300
Files31cf9a532dc8c17640b22be9035aa22a65135af0 /Year 1/Programming introduction/Practice-18.10.21.cpp
uni-projects-2ec5faa88be1447cd93a301543f97ac9d6c312d7.tar
uni-projects-2ec5faa88be1447cd93a301543f97ac9d6c312d7.tar.gz
uni-projects-2ec5faa88be1447cd93a301543f97ac9d6c312d7.zip
Parent475f05d889ae3ffd828211a947305354b56b7f1c (diff)
Added all task descriptions above their corresponding function
1 files changed, 82 insertions, 0 deletions
-rw-r--r--Year 1/Programming introduction/Practice-18.10.21.cpp82
diff --git a/Year 1/Programming introduction/Practice-18.10.21.cpp b/Year 1/Programming introduction/Practice-18.10.21.cpp
index 0b336b3..d279418 100644
--- a/Year 1/Programming introduction/Practice-18.10.21.cpp
+++ b/Year 1/Programming introduction/Practice-18.10.21.cpp
@@ -9,6 +9,13 @@ using namespace std;
* https://github.com/triffon/ip-2021-22/blob/master/practicum/6/week2/%D0%B7%D0%B0%D0%B4%D0%B0%D1%87%D0%B8%20%D0%B2%D1%82%D0%BE%D1%80%D0%B0%20%D1%81%D0%B5%D0%B4%D0%BC%D0%B8%D1%86%D0%B0.pdf
*/
+// Задача 0
+// Дадени са n лева. Да се изведе на конзолата как може да се разпределят по
+// банкноти така, че да имаме минимален брой банкноти. В условието приемаме, че
+// имаме банкноти от 1 и 2 лева.
+// Пример:
+// Вход: 62
+// Изход: 1 * 50 + 1 * 10 + 1 * 2
void ex0() {
int a;
cin >> a;
@@ -30,6 +37,12 @@ void ex0() {
cout << a << " * 1";
}
+// Задача 1
+// Да се напише програма, използваща конструкцията switch, която приема число от
+// 1 до 12, и отпечатва на стандартния изход съответния месец от годината.
+// Пример:
+// Вход: 12
+// Изход: Декември
void ex1() {
int a;
cin >> a;
@@ -50,6 +63,12 @@ void ex1() {
}
}
+// Задача 2
+// В по - долната таблица е представена глобата, която водачът получава, при
+// превишена скорост. Да се изведе получената глоба при въведена скорост.
+// | 50 | 70 | 90 | 110 | 130 | 160 |
+// |----+----+----+-----+-----+-----|
+// | 0 | 20 | 50 | 150 | 350 | 700 |
void ex2() {
int a;
cin >> a;
@@ -62,6 +81,8 @@ void ex2() {
else cout << 0;
}
+// Задача 3
+// Да се въведат три числа и да се изведат на стандартния изход в нарастващ ред.
void ex3() {
int a, b, c;
cin >> a >> b >> c;
@@ -74,6 +95,11 @@ void ex3() {
cout << c << " " << ((b < a) ? b : a) << " " << ((a > b) ? a : b);
}
+// Задача 4
+// От стандартния вход се въвеждат координатите (x1, y1), и (x2, y2), които описват
+// правоъгълник в двуизмерна координатна система и координатите (x, y), които
+// описват точка. Да се изведе на стандартния изход "true"ако точката е в
+// правоъгълника, и "false"в противен случай.
void ex4() {
int x1, y1, x2, y2, x, y;
cin >> x1 >> y1 >> x2 >> y2 >> x >> y;
@@ -82,6 +108,17 @@ void ex4() {
cout << (( ((x > x1 && x < x2) || (x > x2 && x < x1)) && ((y > y1 && y < y2) || (y > y2 && y < y1)) ) ? "true" : "false");
}
+// Задача 5
+// Какво ще изведе програмата:
+// #include <iostream>
+// using namespace std;
+// int main() {
+// int c = 5;
+// int d = (c += 3 ) + (c += 5);
+// cout << d;
+// return 0;
+// }
+// Защо?
void ex5() {
cout << "Will output 26, since = returns a reference and at the end it evaluates to c + c." << endl;
@@ -90,6 +127,18 @@ void ex5() {
cout << d;
}
+// Задача 6
+// Какво ще изведе програмата:
+// #include <iostream>
+// using namespace std;
+// int main() {
+// int c = 5;
+// if (c += c -= 5)
+// cout << (c *= 10);
+// else
+// cout << c;
+// }
+// Защо?
void ex6() {
cout << "Will output 0, = evaluates from the right to the left, so c becomes 0 and we have 0 + 0." << endl;
@@ -100,6 +149,15 @@ void ex6() {
cout << c;
}
+// Задача 7
+// Какво ще изведе програмата:
+// #include <iostream>
+// using namespace std;
+// int main() {
+// int c = 5;
+// cout << ((c == 6) || (c / 0));
+// }
+// Защо?
void ex7() {
cout << "Will output nothing, since you cannot divide by 0" << endl;
@@ -107,6 +165,15 @@ void ex7() {
cout << ((c == 6) || (c / 0));
}
+// Задача 8
+// Какво ще изведе програмата:
+// #include <iostream>
+// using namespace std;
+// int main() {
+// int c = 5;
+// cout << ((c == 6) && (c / 0));
+// }
+// Защо?
void ex8() {
cout << "Will output 0, since comparison is lazy and when it evaluates c == 6 as false, it just returns" << endl;
@@ -114,6 +181,17 @@ void ex8() {
cout << ((c == 6) && (c / 0));
}
+// Задача 9
+// Какво ще изведе програмата:
+// #include <iostream>
+// using namespace std;
+// int main() {
+// int c = 5;
+// double e = 0;
+// cout << ((c = 6) && (e = 1));
+// cout << c << " " << e;
+// }
+// Защо?
void ex9() {
cout << "Will output 16 1, because = returns a reference, which is practically a number, that is more than 0 so it evaluates as true" << endl;
@@ -123,6 +201,10 @@ void ex9() {
cout << c << " " << e;
}
+// Задача 10*:
+// Да се реши квадратно уравнение, като предварително от потребителя са въведени
+// a, b и с където:
+// ax 2 + bx + c = 0
void ex10() {
double a, b, c;
cin >> a >> b >> c;