Jump to content
bodostee

Tranformare in c++

Recommended Posts

  • Active Members
Posted (edited)

Cred ca asta e mot-a-mot cu ce ai tu acolo desi b-ul ala nush de ce nu e float:

 

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n, a, b;
    cout << "n = "; cin >> n;
    
    a = 1;
    b = 1;
    
    while (a*a + b*b <= n) {
        if (a*a + b*b == n) {
            cout << "a = "; cin >> a;
            cout << "b = "; cin >> b;
        }
        a += 1;
        b = sqrt(n - a*a);
    }
    
    cout << "a = " << a << endl;
    cout << "b = " << b << endl;
    
    return 0;
}

 

// LE. Sunt platit foarte bine ca sa ajut lumea la teme. That could be you :( Learn and you'll get rich

Edited by MrGrj
  • Upvote 5

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...