Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. //Marroccia Marco
  2.  
  3. #include<iostream>
  4. #include<fstream>
  5. using namespace std;
  6.  
  7. ifstream fin("input.txt");
  8. ofstream fout("output.txt");
  9.  
  10. int main(){
  11.  
  12. int n,pos_min;
  13. double max,min,Mercato[10000];
  14. for(int i=0; i<10; i++){
  15. fin>>n;
  16. min=100.00;
  17. //carico i valori nell Array Mercato
  18. for(int j=0; j<n; j++){
  19. fin>>Mercato[j];}
  20. for(int h=0;h<n-1;h++)
  21. if(Mercato[h]<min) {min=Mercato[h]; pos_min=h;}
  22. max=0;
  23. for(int k=pos_min+1; k<n; k++){
  24. if(Mercato[k]>max) max=Mercato[k];
  25. }
  26. fout<<max-min<<endl;
  27.  
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement