rezolvati pe o foaie varianta 6 pls in c++ dau coronita.
Răspunsuri la întrebare
Exercitiul 1
#include <iostream>
using namespace std;
int main()
{
int a, b, c;
cin>>a>>b>>c;
if(a==b) cout<<c;
else if(a==c) cout<<b;
else if(b==c) cout<<a;
return 0;
}
Exercitiul 2
#include <iostream>
using namespace std;
int main()
{
int x; float y;
cin>>x;
if(x>=5) y=2*x;
else if(x<3) y=(float)32*x/12;
cout<<y;
return 0;
}
Exercitiul 3
#include <iostream>
using namespace std;
int main()
{
char c;
cin>>c;
if(c=='I') cout<<1;
else if(c=='V') cout<<5;
else if(c=='X') cout<<10;
else if(c=='L') cout<<50;
else if(c=='C') cout<<100;
else if(c=='D') cout<<500;
else if(c=='M') cout<<1000;
return 0;
}
Exercitiul 4
#include <iostream>
using namespace std;
int main()
{
unsigned int N, S=0, P=1, i;
cin>>N;
for(i=1;i<=N;i++)
{
S=S+(2*i)*(2*i);
P=P*(2*i)*(2*i);
}
cout<<"Suma este:"<<S<<endl;
cout<<"Produsul este:"<<P;
return 0;
}
Exercitiul 5
//folosind for
#include <iostream>
using namespace std;
int main()
{
int N, A, i;
cin>>N>>A;
for(i=1;i<=N;i++)
if(i%A==0)
cout<<i<<' ';
return 0;
}
//folosind while
#include <iostream>
using namespace std;
int main()
{
int N, A, i;
cin>>N>>A;
i=1;
while(i<=N)
{
if(i%A==0)
cout<<i<<' ';
i++;
}
return 0;
}
//folosind do while
#include <iostream>
using namespace std;
int main()
{
int N, A, i;
cin>>N>>A;
i=0;
do
{
i++;
if(i%A==0)
cout<<i<<' ';
}
while(i<N);
return 0;
}