Jump to content

[C++]Minimul elementelor dintr-un sir(vector)


AIM Katzuno Valoare
 Share

Recommended Posts



#include <iostream>
#include <math.h>
using namespace std;
// Nivel: incepator
int main()
{
int v[32000], i, min, n;//Am pus vectorul 32000 deoarece, in teorie, aceasta este limita aproximativa a //tipului de date "int", voi puteti schimba in functie de caz, nu prea o sa aveti nevoie de un vector asa de mare, doar pentru olimpiada e posibil, dar rar.
cout << "Limita sirului este: ";
cin >> n;
for (i = 1; i <= n; i++) {
cout << "V[" << i << "]=";
cin >> v[i];
}
min = v[1];
for (i = 1; i <= n; i++) {
if (min > v[i])
min = v[i];
}
cout << "Minimul este " << min << endl;
return 0;
}
Daca aveti nelamuriri sau aveti nevoie de explicatii puteti lasa un reply la acest topic.

Edited by pH Katzuno
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.