Hi guys,I am new here...So, I'm programming for about 6-7 months,I learnt the usual and the basic stuff and right now I'm on objects stuff.Anyway,I have some problems with thinking how to write the program sometimes,I need a little help with:
So,I have a program which returns the minim number from a vector,easy enough.But I want to see also on which position it is the minim number.For example we got:
a[0]=20
a[1]=19
a[2]=1
so,the programs returns 1 because it is the lowest number,and I want the program to show me also a[2] like an adress..
Here's the cod guys.
btw,in cout it is romanian language:)) it means The minim from the vector is :
#include <iostream>
usingnamespace std;
int main ()
{
int n,i,j,a[100];
int min;
cout<<"n="; cin>>n;
for(i=0;i<=n;i++)
{
cout<<"a["<<i<<"]="; cin>>a[i];
}
min=a[0];
for(i=1;i<=n;i++)
{
if (min>a[i])
min=a[i];
}
cout<<"Minimul din vector este : "<<min<<endl;
}
For example if we got ten n's, the lowest number is on the eight vector but the min index shows on the ten vector and so one,just try it on your own :D