Предмет: Информатика,
автор: nasonova20031
Номер 6, 7, 8, 12 написать программы на языке C++
Приложения:
Ответы
Автор ответа:
1
Номер 6:
#include <iostream>
using namespace std;
int main()
{
int num[3];
cout << "Enter three numbers: ";
cin >> num[0] >> num[1] >> num[2];
int sum = 0;
for (int i = 0; i < 3; i++)
{
if (num[i] > 0)
sum = sum + num[i];
}
cout << endl << "Sum = " << sum << endl;
return 0;
}
-----------------------------------------
Номер 7:
#include <iostream>
using namespace std;
int main()
{
int num[3];
cout << "Enter three numbers: ";
cin >> num[0] >> num[1] >> num[2];
int counter = 0;
for (int i = 0; i < 3; i++)
{
if (num[i] % 2 == 0)
counter++;
}
cout << endl << "Even numbers = " << counter << endl;
return 0;
}
-----------------------------------------
Номер 8:
#include <iostream>
using namespace std;
int main()
{
int num1, num2, num3, number;
cout << "Enter number: ";
cin >> number;
if (number > 99 && number < 1000)
{
num1 = number / 100;
num2 = number / 10;
num2 = number % 10;
num3 = number % 10;
if (num1 == num3)
cout << endl << "Palidrom!" << endl;
else
cout << endl << "Not Palidrom!" << endl;
}
else
cout << endl << "Uncorrect number!" << endl;
return 0;
}
-----------------------------------------
Номер 12:
#include <iostream>
using namespace std;
int main()
{
int max, min, central, tmp;
cout << "Enter first number: ";
cin >> max;
cout << "Enter second number: ";
cin >> min;
if (min > max)
{
tmp = max;
max = min;
min = tmp;
}
cout << "Enter third number: ";
cin >> central;
if (central > max)
{
tmp = max;
max = central;
central = tmp;
}
else if (central < min)
{
tmp = min;
min = central;
central = tmp;
}
cout << endl << "Central number = " << central << endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int num[3];
cout << "Enter three numbers: ";
cin >> num[0] >> num[1] >> num[2];
int sum = 0;
for (int i = 0; i < 3; i++)
{
if (num[i] > 0)
sum = sum + num[i];
}
cout << endl << "Sum = " << sum << endl;
return 0;
}
-----------------------------------------
Номер 7:
#include <iostream>
using namespace std;
int main()
{
int num[3];
cout << "Enter three numbers: ";
cin >> num[0] >> num[1] >> num[2];
int counter = 0;
for (int i = 0; i < 3; i++)
{
if (num[i] % 2 == 0)
counter++;
}
cout << endl << "Even numbers = " << counter << endl;
return 0;
}
-----------------------------------------
Номер 8:
#include <iostream>
using namespace std;
int main()
{
int num1, num2, num3, number;
cout << "Enter number: ";
cin >> number;
if (number > 99 && number < 1000)
{
num1 = number / 100;
num2 = number / 10;
num2 = number % 10;
num3 = number % 10;
if (num1 == num3)
cout << endl << "Palidrom!" << endl;
else
cout << endl << "Not Palidrom!" << endl;
}
else
cout << endl << "Uncorrect number!" << endl;
return 0;
}
-----------------------------------------
Номер 12:
#include <iostream>
using namespace std;
int main()
{
int max, min, central, tmp;
cout << "Enter first number: ";
cin >> max;
cout << "Enter second number: ";
cin >> min;
if (min > max)
{
tmp = max;
max = min;
min = tmp;
}
cout << "Enter third number: ";
cin >> central;
if (central > max)
{
tmp = max;
max = central;
central = tmp;
}
else if (central < min)
{
tmp = min;
min = central;
central = tmp;
}
cout << endl << "Central number = " << central << endl;
return 0;
}
Похожие вопросы
Предмет: Математика,
автор: amir329843
Предмет: Информатика,
автор: tanyushkagolov4enko
Предмет: Алгебра,
автор: vstreha320
Предмет: Математика,
автор: evkanch