Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Marroccia Marco
- #include<iostream>
- #include<fstream>
- using namespace std;
- ifstream fin("input.txt");
- ofstream fout("output.txt");
- int main(){
- int n,pos_min;
- double max,min,Mercato[10000];
- for(int i=0; i<10; i++){
- fin>>n;
- min=100.00;
- //carico i valori nell Array Mercato
- for(int j=0; j<n; j++){
- fin>>Mercato[j];}
- for(int h=0;h<n-1;h++)
- if(Mercato[h]<min) {min=Mercato[h]; pos_min=h;}
- max=0;
- for(int k=pos_min+1; k<n; k++){
- if(Mercato[k]>max) max=Mercato[k];
- }
- fout<<max-min<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement