int main() { int a; cin >> a if(a%2 == 0) cout << "четное" << endl; else cout << "нечетное" << endl; }
4) #include <iostream>
using namespace std;
int main() { int a,b,c; string s = ""; cin >> a >> b >> c; if(a == b && a == c) cout << "равносторонний" << endl; else { if (a==b || a == c || b == c) s += "равнобедренный"; if( a*a == (b*b+c*c) || b*b == (a*a+c*c) || c*c == (a*a+b*b)) s+= "прямоугольный"; if(s == '') cout << "обычный" << endl; else cout << s << endl; } }
#include <iostream>
using namespace std;
int main() {
cout << "Сколько Вам лет?" << endl;
int age;
string s;
cin >> age >> s;
}
2)
#include <iostream>
using namespace std;
int main() {
cout << "Сколько Вам лет?" << endl;
int age;
cin >> age;
if(age < 0) cout << "wrong" << endl;
else if(age >= 18) cout << "yes" << endl;
else cout << "no" << endl;
}
3)
#include <iostream>
using namespace std;
int main() {
int a;
cin >> a
if(a%2 == 0) cout << "четное" << endl;
else cout << "нечетное" << endl;
}
4)
#include <iostream>
using namespace std;
int main() {
int a,b,c;
string s = "";
cin >> a >> b >> c;
if(a == b && a == c) cout << "равносторонний" << endl;
else {
if (a==b || a == c || b == c) s += "равнобедренный";
if( a*a == (b*b+c*c) || b*b == (a*a+c*c) || c*c == (a*a+b*b))
s+= "прямоугольный";
if(s == '') cout << "обычный" << endl;
else cout << s << endl;
}
}
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double a, b, c, x1, x2, d;
do{
cout << "Input a: ";
cin >> a;
if (a == 0) {
cout << "Error! a = 0! This isn't a square equation! Try again" << endl;
}
} while (a == 0);
cout << "Input b: ";
cin >> b;
cout << "Input c: ";
cin >> c;
d = b * b - 4. * a * c;
if (d < 0) {
cout << "No roots";
return 1;
}
else if (d == 0) {
cout << "x = " << -b / 2. / a;
return 2;
}
else {
cout << "x1 = " << (-b + sqrt(d)) / 2. / a << ", x2 = " << (-b - sqrt(d)) / 2. / a;
return 0;
}
}