Ajutati-ma va rog ! Am nevoie urgent până la ora 12:00! Dau coroana și 100 de puncte!
Răspunsuri la întrebare
Salut!
Ai toate problemele in C++ mai jos
192.
#include <iostream>
using namespace std;
int main()
{
int n, f, f1 = 1, f2 = 1;
cin >> n;
if (n == 1)
{
cout << f1;
}
else
{
if (n == 2)
{
cout << f1 << " " << f2;
}
else
{
cout << f1 << " " << f2;
for (int i = 3; i <= n; i++)
{
f = f1 + f2;
cout << " " << f;
f1 = f2;
f2 = f;
}
}
}
return 0;
}
193.
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int a = 0, b = 1;
int c;
if (n == 0)
{
cout << a;
return 0;
}
for (int i = 2; i <= n; ++i)
{
c = a + b;
a = b;
b = c;
}
cout << b;
return 0;
}
194.
#include <iostream>
using namespace std;
int main()
{
int n, a = 1, b = 1, c = a + b;
cin >> n;
cout << a << " " << b << " ";
for (int i = 3; c < n; i++)
{
cout << c << " ";
a = b;
b = c;
c = a + b;
}
return 0;
}
195.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n;
cin >> n;
if (((sqrt(5 * (pow(n, 2))+4)) == (int)(sqrt(5 * (pow(n, 2))+4))) || (sqrt(5 * (pow(n, 2))-4)) == (int)sqrt(5 * (pow(n, 2))-4))
{
cout << "DA";
}
else
{
cout << "NU";
}
return 0;
}
196.
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
if (n == 0)
{
cout << 0;
return 0;
}
int a = 0, b = 1;
int c = a + b;
while (c <= n)
{
a = b;
b = c;
c = a + b;
}
if (abs(c - n) >= abs(b - n))
{
cout << b;
}
else
{
cout << c;
}
return 0;
}