va rog frumos am nevoie de b,c si d. Am nevoie de limbaj c++
urgent!!
Răspunsuri la întrebare
Răspuns:
Program b)
#include <iostream>
using namespace std;
int n, num, neg=0, i;
int main()
{
cout << "n="; cin >>n;
cout << "introdu " << n << " numere intregi: " << endl;
for (i=1; i<=n; i++)
{
cin >> num;
if (num<0) ++neg;
}
cout << neg << " negative";
return 0;
}
Program c
#include <iostream>
using namespace std;
int n, num, i;
int main()
{
cout << "n="; cin >> n;
cout << " introdu " << n << " numere intregi: " << endl;
for (i=1; i<=n; i++)
{
cin >> num;
if (num<0) num=-num;
while (num>9) num/=10;
cout << num << " ";
}
return 0;
}
program d
#include <iostream>
using namespace std;
int n,i, num, minim, maxim;
int main()
{
cout << "n="; cin >> n;
cout << " introdu " << n << " numere intregi: " << endl;
cin >> num;
minim=num;
maxim=num;
for (i=2; i<=n; i++)
{
cin >> num;
if (num<minim) minim=num;
if (num>maxim) maxim=num;
}
cout << "maximal este " << maxim << endl;
cout << "minimal este " << minim ;
return 0;
}
Explicație: