Răspuns :
Răspuns:
1.
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
for(int i=a; i>=b; i=i-1)
cout<<i<<" ";
return 0;
}
2.
#include<iostream>
using namespace std;
int main()
{
int a;
cin>>a;
for(int i=1; i<=a; i=i+1)
{
if(a%i==0)
cout<<i<<" ";
}
return 0;
}
3.
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(a>=0 && b>=0 && c>=0)
{
if(b>c)
cout<<b;
else
cout<<c;
}
else
cout<<a+b;
return 0;
}
Explicație:
Răspuns:
1. #include <iostream>
using namespace std;
int main()
{
int a,b,n;
cout<<"a="; cin>>a;
cout<<"b="; cin>>b;
cout<<"Liftul parcurge etajele: "<<endl;
for(n=a; n>=b; n--)
cout<<n<<" ";
return 0;
}
2.#include <iostream>
using namespace std;
int main()
{
int a, d;
cout<<"a="; cin>>a;
cout<<"1 ";
for(d=2; d<=a/2; d++)
if(a%d==0)
cout<<d<<" ";
cout<<a;
return 0;
}
3.#include <iostream>
using namespace std;
int main()
{
int a,b,c,maxim,suma;
cout<<"a="; cin>>a;
cout<<"b="; cin>>b;
cout<<"c="; cin>>c;
if(a>0 && b>0 && c>0)
{
if(b>c) maxim=b;
else maxim=c;
cout<<"Maximul dintre ultimele 2 numere este: "<<maxim;
}
else cout<<"Suma primelor doua numere este: "<<a+b;
return 0;
Explicație: