#1:
#include
#include
int main()
{
srand(time(NULL));
const int arraySize = 10;
int mainArray[arraySize];
for (int i = 0; i < arraySize; i++)
mainArray[i] = rand() % 1000;
int maxNum = mainArray[0];
for (int i = 0; i < arraySize; i++)
if (mainArray[i] > maxNum)
maxNum = array[i];
std::cout << maxNum << std::endl;<br>
system("pause");
return 0;
}
-------------------
#2:
#include
#include
using namespace std;
int main()
{
float
a_coef,
b_coef,
c_coef;
cout << "Input the coefficients (a * x^2 + b * x + c): ";<br> cin >> a_coef >> b_coef >> c_coef;
float res1, res2;
res1 = (-b_coef + sqrt(b_coef * b_coef - 4 * a_coef * c_coef)) / (2 * a_coef);
res2 = (-b_coef - sqrt(b_coef * b_coef - 4 * a_coef * c_coef)) / (2 * a_coef);
cout << res1 << "; " << res2 << endl;<br>
system("pause");
return 0;
}
-------------------
#3:
#include
#include
int main()
{
srand(time(NULL));
int
unknownNumber = rand() % 100 - 50,
attempts = 0,
inputtedNumber;
while (true)
{
attempts++;
cout << "Input the number: ";<br> cin >> inputtedNumber;
if (inputtedNumber != unknownNumber)
cout << "Incorrect answer! Try again!" << endl;<br> else
break;
}
cout << "Attempts: " << attempts;<br>
system("pause");
return 0;
}