Fix Lesson 1
This commit is contained in:
parent
c1ab9980d4
commit
0ae4eb5552
7 changed files with 65 additions and 52 deletions
|
@ -1,7 +1,10 @@
|
|||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Stanislav" << std::endl << "Mykhailenko" << std::endl;
|
||||
cout << "Stanislav" << endl;
|
||||
cout << "Mykhailenko" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
float firstNumber = 0;
|
||||
float secondNumber = 0;
|
||||
|
||||
std::cout << "Enter the first number: ";
|
||||
std::cin >> firstNumber;
|
||||
cout << "Enter the first number: ";
|
||||
cin >> firstNumber;
|
||||
|
||||
std::cout << "Enter the second number: ";
|
||||
std::cin >> secondNumber;
|
||||
cout << "Enter the second number: ";
|
||||
cin >> secondNumber;
|
||||
|
||||
std::cout << firstNumber + secondNumber << std::endl;
|
||||
cout << firstNumber + secondNumber << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
int money = 0;
|
||||
std::cout << "How much money do you earn? ";
|
||||
std::cin >> money;
|
||||
cout << "How much money do you earn? ";
|
||||
cin >> money;
|
||||
|
||||
if (money < 1000)
|
||||
std::cout << "Work more. ";
|
||||
cout << "Work more. ";
|
||||
if (money > 1000) {
|
||||
if (money > 1000000)
|
||||
std::cout << "You are a millionaire. ";
|
||||
cout << "You are a millionaire. ";
|
||||
if (money < 1000000)
|
||||
std::cout << "You work great. ";
|
||||
cout << "You work great. ";
|
||||
}
|
||||
|
||||
std::cout << "You are doing great!" << std::endl;
|
||||
cout << "You are doing great!" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
float firstNumber = 0;
|
||||
float secondNumber = 0;
|
||||
float result = 0;
|
||||
char operation;
|
||||
char operation = 0;
|
||||
|
||||
std::cout << "Enter the first number: ";
|
||||
std::cin >> firstNumber;
|
||||
cout << "Enter the first number: ";
|
||||
cin >> firstNumber;
|
||||
|
||||
std::cout << "Enter the second number: ";
|
||||
std::cin >> secondNumber;
|
||||
cout << "Enter the second number: ";
|
||||
cin >> secondNumber;
|
||||
|
||||
std::cout << "Enter operation: ";
|
||||
std::cin >> operation;
|
||||
cout << "Enter operation: ";
|
||||
cin >> operation;
|
||||
|
||||
switch (operation) {
|
||||
case '+':
|
||||
|
@ -28,18 +30,18 @@ int main()
|
|||
break;
|
||||
case '/':
|
||||
if (secondNumber == 0) {
|
||||
std::cout << "Division by zero" << std::endl;
|
||||
cout << "Division by zero" << endl;
|
||||
return 1;
|
||||
}
|
||||
result = firstNumber / secondNumber;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unknown operation." << std::endl;
|
||||
cout << "Unknown operation." << endl;
|
||||
return 2;
|
||||
break;
|
||||
}
|
||||
|
||||
std::cout << result << std::endl;
|
||||
cout << result << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include <complex>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
float a = 0;
|
||||
|
@ -9,24 +11,24 @@ int main()
|
|||
float c = 0;
|
||||
float D = 0;
|
||||
|
||||
std::cout << "Enter a: ";
|
||||
std::cin >> a;
|
||||
cout << "Enter a: ";
|
||||
cin >> a;
|
||||
|
||||
std::cout << "Enter b: ";
|
||||
std::cin >> b;
|
||||
cout << "Enter b: ";
|
||||
cin >> b;
|
||||
|
||||
std::cout << "Enter c: ";
|
||||
std::cin >> c;
|
||||
cout << "Enter c: ";
|
||||
cin >> c;
|
||||
|
||||
D = pow(b, 2) - 4 * a * c;
|
||||
|
||||
std::complex<float> root = std::sqrt(std::complex<float>(D));
|
||||
complex<float> root = sqrt(complex<float>(D));
|
||||
|
||||
std::complex<float> x1 = (-b + root) / (2 * a);
|
||||
std::complex<float> x2 = (-b - root) / (2 * a);
|
||||
complex<float> x1 = (-b + root) / (2 * a);
|
||||
complex<float> x2 = (-b - root) / (2 * a);
|
||||
|
||||
std::cout << "x1 = " << x1 << std::endl;
|
||||
std::cout << "x2 = " << x2 << std::endl;
|
||||
cout << "x1 = " << x1 << endl;
|
||||
cout << "x2 = " << x2 << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,25 +1,27 @@
|
|||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
std::cout << "Enter size: ";
|
||||
std::cin >> size;
|
||||
cout << "Enter size: ";
|
||||
cin >> size;
|
||||
|
||||
for (int iteration = 0; iteration < size; ++iteration) {
|
||||
int spaces = size - iteration - 1;
|
||||
int asterisks = 1 + iteration * 2;
|
||||
for (int space = 0; space < spaces; ++space)
|
||||
std::cout << " ";
|
||||
cout << " ";
|
||||
for (int asterisk = 0; asterisk < asterisks; ++asterisk)
|
||||
std::cout << "*";
|
||||
std::cout << std::endl;
|
||||
cout << "*";
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
for (int space = 0; space < size - 1; ++space)
|
||||
std::cout << " ";
|
||||
std::cout << "*" << std::endl;
|
||||
cout << " ";
|
||||
cout << "*" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
float x = 0;
|
||||
|
@ -8,23 +10,21 @@ int main()
|
|||
float N = 0;
|
||||
float distance = 0;
|
||||
|
||||
std::cout << "x = ";
|
||||
std::cin >> x;
|
||||
cout << "Enter your x: ";
|
||||
cin >> x;
|
||||
|
||||
std::cout << "y = ";
|
||||
std::cin >> y;
|
||||
cout << "Enter your y: ";
|
||||
cin >> y;
|
||||
|
||||
std::cout << "N = ";
|
||||
std::cin >> N;
|
||||
|
||||
if (x > N || y > N) {
|
||||
std::cout << "Beyond radius." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
cout << "Enter radius N: ";
|
||||
cin >> N;
|
||||
|
||||
distance = sqrt(pow(x, 2) + pow(y, 2));
|
||||
|
||||
std::cout << distance << std::endl;
|
||||
cout << distance << " from the center";
|
||||
if (distance > N)
|
||||
cout << " (beyond radius)";
|
||||
cout << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Reference in a new issue