bodostee Posted March 8, 2022 Report Posted March 8, 2022 Inceput Intregi n,a,b; Citeste n; a<-1; b<=1; Cat timp a*a+b*b<=n executa Daca a*a+b*b=n; Scrie a,b; Sfarsit Daca a<-a+1; b<-[radical(n-a*a)]; Sfarsit Cat timp Sfarsit Quote
Active Members MrGrj Posted March 8, 2022 Active Members Report Posted March 8, 2022 (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 March 8, 2022 by MrGrj 5 Quote