Daffodil International University
Problem Link
//Please follow from main function
#include<stdio.h>
int main(){
int arr[1000], i, n, loc, low, max=0;
scanf("%d", &n);
for(i=0; i<n; i++){
scanf("%d", &arr[i]);
}
for(i=0; i<n; i++){
if(arr[i]>max){
max=arr[i];
}
}
low=max;
for(i=0; i<n; i++){
if(arr[i]<low){
low=arr[i];
}
}
for(i=0; i<n; i++){
if(arr[i]==low){
loc=i;
break;
}
}
printf("Menor valor: %d\n", low);
printf("Posicao: %d\n", i);
return 0;
}
0 Comments