Ad
Code
Diff
  • #include<iostream>
    
    int doubleValue(int x) {
        return x << 1;
    }
    
    • #include<iostream>
    • int doubleValue(int x) {
    • return x * 2;
    • return x << 1;
    • }
Code
Diff
  • #include <iostream>
    using namespace std;
    int mai()
    {
        int x = 1;
        int u = 0, g = 0, c = 0;
        cout << "quanti anni ha l'uomo? (alla donna non si chiede)" << endl;
        cin >> u;
        while (x <= u)
        {
            if (x >= 1){
                g = 15;
                c = 15;
              }
            if (x >= 2) {
                g += 9;
                c += 9;
            }
            if (x >= 3) {
                g += 4;
                c += 5;
            }
            x++;
        }
        cout << "cane " << c << endl;
        cout << "gatto " << g;
        return 0;
    }
    • #include <iostream>
    • using namespace std;
    • int mai()
    • {
    • int x = 1;
    • int u = 0, g = 0, c = 0;
    • cout << "quanti anni ha l'uomo? (alla donna non si chiede)" << endl;
    • cin >> u;
    • while (x <= u)
    • {
    • if (x == 1)
    • {
    • if (x >= 1){
    • g = 15;
    • c = 15;
    • }
    • if (x == 2) {
    • }
    • if (x >= 2) {
    • g += 9;
    • c += 9;
    • }
    • if (x >= 3) {
    • g += 4;
    • c += 5;
    • }
    • x++;
    • }
    • cout << "cane " << c << endl;
    • cout << "gatto " << g;
    • return 0;
    • }