Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 1
- #include <iostream>
- using namespace std;
- int main() {
- unsigned int a, b;
- cin >> a >> b;
- if (a > b) {
- cout << a << " este mai mare decat " << b << ", ";
- return 0;
- } else {
- if (b == a) {
- cout << "numere egale, ";
- return 0;
- } else {
- cout << b << " este mai mare decat " << a << ". ";
- return 0;
- }
- }
- return 0;
- }
- // 2
- int f(int a, int b) {
- if ((a % 2 == 0) && (b % 2 == 0)) {
- return a + b;
- } else {
- if ((a % 2 == 1) && (b % 2 == 1))
- return a - b;
- else
- return a * b;
- }
- }
- // 3
- #include <iostream>
- using namespace std;
- int f(int x) {
- if (x <= 3)
- return (x > 1);
- if (x % 2 == 0 || x % 3 == 0)
- return 0;
- for (int i = 5; i * i <= x; i = i + 6) {
- if (x % i == 0 || x % (i + 2) == 0)
- return 0;
- }
- return 1;
- }
- int main() {
- int a;
- cin >> a;
- if(f(a)==1)
- cout<<a<<" este prim.";
- else cout<<a<<" nu este prim.";
- return 0;
- }
Add Comment
Please, Sign In to add comment